Forum
CS2D Scripts save filesave file
7 replies 1
join and leave
With conjunction with file:open, file:write, file:read, and file:close, as well as the datatype of your choice (plaintext, json, serialized, pickle, custom), you can load and read usgn save files.
To get player USID you can use player(id,"usgn"), player.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if a==nil then a={} function initArray(m) 	local array = {} 	for i = 1,m do 		array[i]=0 	end 	return array end level=initarray(32) addhook("kill","a.kill") function a.kill(id) 	level[id]=level[id]+1 	end end
How to make save file for it?
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
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
a=a or {} function initArray(m) 	local array = {} 	for i = 1,m do 		array[i]=0 	end 	return array end level=initarray(32) addhook("kill","a.kill") function a.kill(id) 	level[id]=level[id]+1 end addhook("leave","a.leave") function a.leave(id) 	if player(id,"usgn")>0 then 		local temp=io.open("sys/lua/gelap/"..player(id,"usgn")..".txt","w") 		temp:write(level[id]) 		temp:close() 	end 	level[id]=0 end addhook("join","a.join") function a.join(id) 	level[id]=0 	if player(id,"usgn")>0 then 		local temp=io.open("sys/lua/gelap/"..player(id,"usgn")..".txt","r") 		if temp then 			level[id]=tonumber(temp:read("*a")) 		end 	end end addhook("minute","a.minute") function a.minute() 	for _, id in pairs(player(0,"table")) do 		if player(id,"usgn")>0 then 			local temp=io.open("sys/lua/gelap/"..player(id,"usgn")..".txt","w") 			temp:write(level[id]) 			temp:close() 		end 	end end
I also add a leave hook for saving.
Also you need to add "gelap" folder at "sys/lua"
edited 1×, last 04.08.13 03:43:17 am
Gajos has written
Make your script like this lua Score save system. (5)
I lol'd
Admin/mod comment
§2.1 - No needless and/or doubled posts (spam)Thank you all.These help me continued my scription.Thank you thank you thank you thank you.
1