Forum

> > CS2D > Scripts > Script doesn't work for VPS-Server
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script doesn't work for VPS-Server

3 replies
To the start Previous 1 Next To the start

old Script doesn't work for VPS-Server

NeverLast
User Off Offline

Quote
Hello,
This script doesn't work for a Server ,the score/deaths load function don't work,but in "New Game" it work,any idea?
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
savestr={}

function readfile(filelocation, linenum) 
saveline=1
for line in io.lines(filelocation) do 
savestr[saveline]=line
saveline=saveline+1
end
return savestr[linenum]
end

addhook("kill","a_save")
function a_save(id)
usgn = player(id,"usgn")
local c = player(id,"score")
if usgn ~= 0 then
SScore = io.open("sys/lua/Scores/"..player(id,"usgn")..".txt", "w")
SScore:write(""..c.."")
SScore:close()
return 1
end
end
addhook("die","b_save")
function b_save(id)
usgn = player(id,"usgn")
local c2 = player(id,"deaths")
if usgn ~= 0 then
SScore2 = io.open("sys/lua/Scores/"..player(id,"usgn").."_2.txt", "w")
SScore2:write(""..c2.."")
SScore2:close()
return 1
end
end

addhook("join","a_load")
function a_load(id)
usgn = player(id,"usgn")
if usgn ~= 0 then
score = readfile("sys/lua/Scores/"..player(id,"usgn")..".txt", 1)-1+1
parse("setscore "..id.." "..score)
msg2(id,"©000255000Your score was succesfully loaded")
return 1
end
end

addhook("join","b_load")
function b_load(id)
usgn = player(id,"usgn")
if usgn ~= 0 then
score2 = readfile("sys/lua/Scores/"..player(id,"usgn").."_2.txt", 1)-1+1
parse("setdeaths "..id.." "..score2)
msg2(id,"©000255000Your deaths was succesfully loaded")
return 1
end
end

old Re: Script doesn't work for VPS-Server

Dousea
User Off Offline

Quote
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
function updatefile (path, ...)
	local file = io.open (path, "w+")
	
	for key, values in ipairs (arg) do
		file:write (tostring (values) .. "\n")
	end
	
	file:close ()
end

addhook ("spawn", "loadhook")

function loadhook (id)
	if (player (id, "usgn") > 0) then
		local file = io.open ("sys/lua/scores/" .. player (id, "usgn") .. ".cfg")
		
		if (file) then
			local count = 0
			
			for line in file:lines () do
				count = count + 1
				
				if (count == 1) then
					parse ("setscore " .. id .. " " .. line)
				elseif (count == 2) then
					parse ("setdeaths " .. id .. " " .. line)
				end
			end
		end
	end
end

for key, hook in pairs ({"kill", "die"}) do
	addhook (hook, "savehook")
end

function savehook (id)
	if (player (id, "usgn") > 0) then
		updatefile ("sys/lua/scores/" .. player (id, "usgn") .. ".cfg", player (id, "score"), player (id, "deaths"))
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview