Forum

> > CS2D > Scripts > couldnt find delete topic button, sorry
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch couldnt find delete topic button, sorry

26 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Re: couldnt find delete topic button, sorry

EP
User Off Offline

Zitieren
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+")

alt Re: couldnt find delete topic button, sorry

EP
User Off Offline

Zitieren
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

alt Re: couldnt find delete topic button, sorry

VADemon
User Off Offline

Zitieren
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.
1× editiert, zuletzt 15.08.12 03:00:52

alt Re: couldnt find delete topic button, sorry

EngiN33R
Moderator Off Offline

Zitieren
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:

Mehr >


@user VADemon: There's tostring for that.

alt Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

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

alt Re: couldnt find delete topic button, sorry

omg
User Off Offline

Zitieren
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

alt Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Zitieren
@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

alt Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Zitieren
@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)
3× editiert, zuletzt 15.08.12 18:15:28

alt Re: couldnt find delete topic button, sorry

EP
User Off Offline

Zitieren
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.

alt Re: couldnt find delete topic button, sorry

loldlold123
User Off Offline

Zitieren
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

alt Re: couldnt find delete topic button, sorry

Infinite Rain
Reviewer Off Offline

Zitieren
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
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht