(Even though shutting it down gives me EXCEPTION_ACCESS_VIOLATION, but that's besides the point)
Forum
Scripts
[Solved] Hat code now broken!
[Solved] Hat code now broken!
25 replies(Even though shutting it down gives me EXCEPTION_ACCESS_VIOLATION, but that's besides the point)
It does not work for me, I tested the code on 2 computers.
cs2d_is_a_Gem has writtenI tested the code on 2 computers.
2 computers? Quick check: Does both of them have the files?
gfx/hat/devil.png gfx/hat/skull.png gfx/hat/Soldado ct.png gfx/hat/Soldado tt.png gfx/hat/captain america hat by spike.png
Because if one of them doesn't, you'll need to add these to server-transfer.
I do not understand why the code is working correctly for you.
edited 1×, last 10.05.18 03:10:41 am
cs2d_is_a_Gem has writtenwhen joining the game aparesco without hat and leaving the game my data is saved in 0 as if I had never selected a hat.
Well I did remove the "save/load from file" portion of the script when I ran my own test.
After factoring in that portion... Well I replaced the join and leave functions with this:
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
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
addhook("leave","savedata")
function savedata(id,reason)
	if player(id,"usgn") > 0 then
		local f = assert(io.open("sys/lua/hats/saves/"..player(id,"usgn")..".txt","w"))
		f:write(tostring(currenthat[id]))
		f:close()
	end
	if hatimg[id] then
		freeimage(hatimg[id])
	end
	hatimg[id] = nil
	currenthat[id] = nil
end
addhook("join","loaddata")
function loaddata(id)
	local loaded = false
	if player(id,"usgn") > 0 then
		local f = io.open("sys/lua/hats/saves/"..player(id,"usgn")..".txt","r")
		if f ~= nil then
			for line in f:lines() do
				if line then
					currenthat[id] = tonumber(line)
					loaded = true
					break
				end
			end
			f:close()
		end
	end
	if not loaded then
		currenthat[id] = 0
	end
end
io.openfunctions.
edited 2×, last 11.05.18 07:10:29 am



Offline
