couldnt find delete topic button, sorry
26 replies Change this:
To this:
Code:
1
file = assert(io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+"))
To this:
Code:
1
file = io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+")
LUA ERROR: sys/lua/savenload.lua:3: attempt to concatenate a boolean value
dafuq is that
Code:
1
file = io.open("allsavedatas/arraysaves/"..player(id,"usgn")..".txt","w+")
dafuq is that
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.
You could use this function to make it 1 or 0 depending of it's boolean value.
Code:
And to make it boolean again use this: 1
2
3
4
5
6
2
3
4
5
6
function booltoint(bool)
if bool then
return 1
end
return 0
end
if bool then
return 1
end
return 0
end
Code:
1
2
3
4
5
6
2
3
4
5
6
function inttobool(int)
if int == 1 then
return true
end
return false
end
if int == 1 then
return true
end
return false
end
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.
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
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:
@
VADemon: There's tostring for that.
@

I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
@
loldlold123: YeS BeCaUsE ThAt'S A BoOlEaN VaLuE BuT It HaS To Be An InTeGeR So YoU OnLy HaZ To Uze tonumber()

Code:
Understood? Understood. 1
money[id]=tonumber(player_dat[id][2])
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
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
will code for food
@
omg: DiD YoU ReAd ThE PoSt ThAt HeAdSuCkEr WrOtE? ThErE WaS A CoNdItIoN ThAt WaS CoMpArInG An InTeGeR WiTh A BoOlEaN VaLuE. So PlEaSe ReAd It AgAiN AnD ThInK BeFoRe PoSt.
?
.



@
omg: and @
CowsCowsEverywhere: i used your both solutions,it works but there is still error in console in third line and @
CowsCowsEverywhere: try to writing NoRmAl next time
here's error LUA ERROR: sys/lua/savenload.lua:3: attempt to concatenate a boolean value



here's error LUA ERROR: sys/lua/savenload.lua:3: attempt to concatenate a boolean value
Code:
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
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
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
@
loldlold123: wtf? Why do you tostring() everything?. Use tostring() for each value not for everything. That should work. Great that you see....

edited 1×, last 15.08.12 05:59:01 pm
Why do you want money to be boolean?
Code:
Tell us which values have to be string/boolean/integer please. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
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
i dont want any god damn boolean or other shits
every varible is that array,and everthing has to be numbers
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)
.....
...
..
.
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
Why do you people keep using the Array(32) SHIT?!
Why don't you just create table with all data for each player!!
DAMN
Why don't you just create table with all data for each player!!
DAMN
Code:
1
2
3
4
5
6
7
8
9
10
11
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
addhook('join', 'joinhook')
function joinhook(id)
Player[id] = {
money = 0;
credits = 0;
timescrapped = 0;
sexappeal = 13;
fapped = 13;
}
end
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
@
Infinite Rain: He stills using the array function because his Player[id] didn't fap yet. Not even 13 times.


@
Infinite Rain: He stills using the array function because his Player[id] didn't fap yet. Not even 13 times.

A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV