English couldnt find delete topic button, sorry

26 replies
Goto Page
To the start Previous 1 2 Next To the start
Up
loldlold123
User
Offline Off
couldnt find delete topic button, sorry
edited 2×, last 03.08.14 10:38:18 am
14.08.12 03:34:27 pm
Up
EP
User
Offline Off
Change 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+")
14.08.12 04:07:46 pm
Up
loldlold123
User
Offline Off
LUA ERROR: sys/lua/savenload.lua:3: attempt to concatenate a boolean value

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

dafuq is that
14.08.12 04:16:18 pm
Up
EP
User
Offline Off
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.
Code:
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:
Code:
1
2
3
4
5
6
function inttobool(int)
     if int == 1 then 
          return true
     end
     return false
end
14.08.12 04:22:31 pm
Up
loldlold123
User
Offline Off
siriously,i dont understant it.
14.08.12 09:01:19 pm
Up
VADemon
User
Offline Off
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
15.08.12 10:52:11 am
Up
EngiN33R
Moderator
Offline Off
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.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
15.08.12 02:16:08 pm
Up
loldlold123
User
Offline Off
@user EngiN33R: i done what you said and its still doesnt work
Spoiler >
15.08.12 04:19:16 pm
Up
CowsCowsEverywhere
BANNED
Offline Off
@user loldlold123: YeS BeCaUsE ThAt'S A BoOlEaN VaLuE BuT It HaS To Be An InTeGeR So YoU OnLy HaZ To Uze tonumber()
Code:
1
money[id]=tonumber(player_dat[id][2])
Understood? Understood.
15.08.12 04:25:48 pm
Up
omg
User
Offline Off
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
will code for food
15.08.12 04:29:29 pm
Up
CowsCowsEverywhere
BANNED
Offline Off
@user 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.
√ ?
√ .
15.08.12 05:20:46 pm
Up
loldlold123
User
Offline Off
@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

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
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
15.08.12 05:24:27 pm
Up
EP
User
Offline Off
@user 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
15.08.12 05:44:59 pm
Up
loldlold123
User
Offline Off
@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
15.08.12 06:22:57 pm
Up
EP
User
Offline Off
Why do you want money to be boolean?
Code:
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.
15.08.12 06:25:34 pm
Up
loldlold123
User
Offline Off
i dont want any god damn boolean or other shits

Code:
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
15.08.12 06:32:19 pm
Up
Infinite Rain
Reviewer
Offline Off
Why do you people keep using the Array(32) SHIT?!
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
Player = {}
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
15.08.12 06:33:52 pm
Up
EP
User
Offline Off
@user Infinite Rain: He stills using the array function because his Player[id] didn't fap yet. Not even 13 times.
15.08.12 06:35:14 pm
Up
Infinite Rain
Reviewer
Offline Off
user EP has written:
@user Infinite Rain: He stills using the array function because his Player[id] didn't fap yet. Not even 13 times.
Lol what?
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
15.08.12 06:40:03 pm
Up
VADemon
User
Offline Off
Array itself isn't that bad. Worser is, that it's a global.
file too.
To the start Previous 1 2 Next To the start