Forum

> > CS2D > Scripts > My Rank Script do not save..
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch My Rank Script do not save..

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt My Rank Script do not save..

Lag Seeing
User Off Offline

Zitieren
Hey Guys , i was making a Rank / level script and it doesn't save in my "SAVES" folder .. here is the Lua 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
level=initArray(32)
exp=initArray(32)
asd=initArray(32)

function string.split(text,b)
local cmd = {}
if b then
b = b
else
b = "%s"
end
b = "[^"..b.."]+"
for o in string.gmatch(text,b) do
table.insert(cmd,o)
end
return cmd
end

addhook("ms100","ms_hud")
function ms_hud()
     for id = 1,32 do
          if (player(id,"exists")) then 		
	       asd[id]=500*level[id]+500	               		
               parse('hudtxt2 '..id..' 48 "©000255010 Rank: '..level[id]..' " 13 117')
               parse('hudtxt2 '..id..' 49 "©010255000 Points: '..exp[id]..'/'..asd[id]..' " 13 129')
	  end	 		
      end
end

addhook("objectkill","objectkill")
function objectkill(id,player)
if exp[player] < asd[player] then 
exp[player]=exp[player]+100
end	
if exp[player] == asd[player] or exp[player] > asd[player] then
exp[player]=0
level[player]=level[player]+1
msg2(player,"©000255000Rank up!@C")
msg("©255075000"..player(id,"name").." reached "..level[player].." level!")
end
end

addhook("kill","ms_kill")
function ms_kill(id)
if exp[id] < asd[id] then 
exp[id]=exp[id]+100
end	
if exp[id] == asd[id] or exp[id] > asd[id] then
exp[id]=0
level[id]=level[id]+1
msg2(id,"©000255000Rank up!@C")
msg("©255075000"..player(id,"name").." reached "..level[id].." level!")
end
end

addhook("spawn","pl_spawn")
	function pl_spawn(id)
		if level[id] < 0 then
			id=image("gfx/sf_rank_01.bmp",0,0,132+id)
			imagecolor(id,255,255,0)
			imageblend(id,1)
			imagealpha(id,0.5)
		elseif level[id] >=0 and level[id] <4 then
		id=image("gfx/sf_rank_02.bmp",0,0,132+id)
			imagecolor(id,255,100,255)
			imageblend(id,1)
			imagealpha(id,0.5)
		elseif level[id] >=5 and level[id] <10 then
		id=image("gfx/sf_rank_03.bmp",0,0,132+id)
			imagecolor(id,100,100,100)
			imageblend(id,1)
			imagealpha(id,0.5)
		elseif level[id] >=11 and level[id] < 14 then
		id=image("gfx/sf_rank_04.bmp",0,0,132+id)
			imagecolor(id,255,0,255)
			imageblend(id,1)
			imagealpha(id,0.5)
		elseif level[id] >=15 and level[id] < 20 then
		id=image("gfx/sf_rank_05.bmp",0,0,132+id)
			imagecolor(id,0,255,255)
			imageblend(id,1)
			imagealpha(id,0.5)
		elseif level[id] >=21 then
			id=image("gfx/sf_rank_06.bmp",0,0,132+id)
			imagecolor(id,255,0,0)
			imageblend(id,1)
			imagealpha(id,0.5)
		end		
end


addhook("leave","save_leave")
function save_die(id)
     if (player(id,"usgn")>83664) then
          io.output(io.open("sys/lua/saves/"..player(id,"usgn")..".txt","w+"))
          io.write(exp[id].." "..level[id])
          io.close()
     end
end

addhook("die","save_die")
function save_die(id)
     if (player(id,"usgn")>83664) then
          io.output(io.open("sys/lua/saves/"..player(id,"usgn")..".txt","w+"))
          io.write(exp[id].." "..level[id])
          io.close()
     end
end

addhook("join","save_join")
function save_join(id)
     if (player(id,"usgn")>83664) then
          for line in io.lines("sys/lua/saves/"..player(id,"usgn")..".txt") do
               line = line:split()
               local ms_exp = tonumber(line[1])
               local ms_level = tonumber(line[2])
               level[id]=ms_level
               exp[id]=ms_exp
          end
     end
end
Please Reply..

alt Re: My Rank Script do not save..

DarkLight66
User Off Offline

Zitieren
eh...

1
if (player(id,"usgn")>83664) then

why did you put your usgn there? that line means it will save ONLY usgns over that number, but not equal or less, you should change that number to 0.

alt Re: My Rank Script do not save..

Jaller94
User Off Offline

Zitieren
1
if (player(id,"usgn")~=83664) then

should fix that problem if you really want to exclude yourself
"~=" means "not equal"
also make sure that the dir exists.

EDIT: DarkLight66 ist right; you also need to check that the usgn ist not 0 (no login)
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht