Forum

> > CS2D > Scripts > couldnt find delete topic button, sorry
Forums overviewCS2D overview Scripts overviewLog in to reply

English couldnt find delete topic button, sorry

26 replies
Page
To the start Previous 1 2 Next To the start

old Re: couldnt find delete topic button, sorry

EP
User Off Offline

Quote
Change this:

1
file = assert(io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+"))

To this:

1
file = io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+")

old Re: couldnt find delete topic button, sorry

EP
User Off Offline

Quote
You're trying to write a boolean value in a .txt file.
You could use this function to make it 1 or 0 depending of it's boolean value.
1
2
3
4
5
6
function booltoint(bool)
	if bool then 
		return 1 
	end 
	return 0 
end
And to make it boolean again use this:
1
2
3
4
5
6
function inttobool(int)
	if int == 1 then 
		return true
	end
	return false
end

old Re: couldnt find delete topic button, sorry

VADemon
User Off Offline

Quote
if type(x)=="boolean" then
if x then
io.write(file,"true")
end
file:write("false")
end


Just answer whether you understood / resolved it or not.
edited 1×, last 15.08.12 03:00:52 am

old Re: couldnt find delete topic button, sorry

EngiN33R
Moderator Off Offline

Quote
Your error is caused by the fact that you try to concatenate (..) a boolean value (true/false) with a string. It doesn't work like that in Lua, you have to convert it to a value that can be concatenated - either an integer or a string. You could use the solution provided by Blairstring, or you can do the following:

More >


@user VADemon: There's tostring for that.

old Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Quote
@user EngiN33R: i done what you said and its still doesnt work
Spoiler >

old Re: couldnt find delete topic button, sorry

omg
User Off Offline

Quote
are people really that clueless? the boolean is coming from invalid player(id,"usgn"), provided that this is the second line of the code

just check to see if id>0 and player(id,"usgn")~=0. if the id isnt between 1 and 32, trying to get a value from the id will return false, as far as i know

old Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Quote
@user omg: and @user CowsCowsEverywhere: i used your both solutions,it works but there is still error in console in third line and @user CowsCowsEverywhere: try to writing NoRmAl next time

here's error LUA ERROR: sys/lua/savenload.lua:3: attempt to concatenate a boolean value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function saves(id)
	if player(id,"usgn")~=0 and id>0 and id<33 then
file = io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+") --HERE THIRD LINE
file:write(tostring(career[id].." "..money[id].." "..aclik[id].." "..referer[id].." "..jail[id].." "..saycolor[id].." "..mute[id].." "..locked[id].." "..commandcooldown[id].." "..shootingrange[id]))
file:close()
msg2(id,'©107142035Save Game Successfull!@C')
end
end

	 player_dat={}
function loads(id)
     if player(id,"usgn")~=0 and id>0 and id<33 then
          for line in io.lines("allsavedatas/arraysaves/"..player(id,"usgn")..".txt") do
               player_dat[id]={line:match("(.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*)")}
			   career[id]=tonumber(player_dat[id][1])
			   money[id]=tonumber(player_dat[id][2])
			   aclik[id]=tonumber(player_dat[id][3])
			   referer[id]=tonumber(player_dat[id][4])
			   jail[id]=tonumber(player_dat[id][5])
			   saycolor[id]=tonumber(player_dat[id][6])
			   mute[id]=tonumber(player_dat[id][7])
			   locked[id]=tonumber(player_dat[id][8])
			   commandcooldown[id]=tonumber(player_dat[id][9])
			   shootingrange[id]=tonumber(player_dat[id][10])
          end
     end
end

old Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Quote
@user EP:oh i see
done,it doesnt work.
Spoiler >



btw can some one add if file exists then code? to load code? (usgn.txt)
edited 3×, last 15.08.12 06:15:28 pm

old Re: couldnt find delete topic button, sorry

EP
User Off Offline

Quote
Why do you want money to be boolean?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function loads(id)
     if player(id,"usgn")~=0 and id>0 and id<33 then
          for line in io.lines("allsavedatas/arraysaves/"..player(id,"usgn")..".txt") do
               player_dat[id]={line:match("(.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*) (.*)")}
                  career[id]=tobool(player_dat[id][1])
                  money[id]=tonumber(player_dat[id][2])
                  aclik[id]=tobool(player_dat[id][3])
                  referer[id]=tobool(player_dat[id][4])
                  jail[id]=tobool(player_dat[id][5])
                  saycolor[id]=tobool(player_dat[id][6])
                  mute[id]=tobool(player_dat[id][7])
                  locked[id]=tobool(player_dat[id][8])
                  commandcooldown[id]=tobool(player_dat[id][9])
                  shootingrange[id]=tobool(player_dat[id][10])
          end
     end
end
Tell us which values have to be string/boolean/integer please.

old Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Quote
i dont want any god damn boolean or other shits

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function Array(p)
    local array = {}
    for i = 1, p do
        array[i]=0
    end
    return array
end

money=Array(32)
career=Array(32)
kredi=Array(32)
aclik=Array(32)
.....
...
..
.

every varible is that array,and everthing has to be numbers

old Re: couldnt find delete topic button, sorry

Infinite Rain
Reviewer Off Offline

Quote
Why do you people keep using the Array(32) SHIT?!
Why don't you just create table with all data for each player!!
DAMN

1
2
3
4
5
6
7
8
9
10
11
Player = {}
addhook('join', 'joinhook')
function joinhook(id)
	Player[id] = {
		money = 0;
		credits = 0;
		timescrapped = 0;
		sexappeal = 13;
		fapped = 13;
	}
end
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview