Forum

> > CS2D > Scripts > Save Items In Inventory
Forums overviewCS2D overview Scripts overviewLog in to reply

English Save Items In Inventory

8 replies
To the start Previous 1 Next To the start

old Re: Save Items In Inventory

omg
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
42
43
44
for i=1,32 do
	inventory[i]=""
end

addhook("leave","por_favor")
function por_favor(id)
	if player(id,"usgn")~=0 then
		local file=io.open("sys/lua/"..player(id,"usgn")..".txt","w")
		local str=""
		for _,weapon in pairs(playerweapons(id)) do
			str=str..weapon..","
		end
		file:write(string.sub(str,1,#str-1))
		file:close()
	end
end

addhook("join","lolnado")
function lolnado(id)
	if player(id,"usgn")~=0 then
		local file=io.open("sys/lua/"..player(id,"usgn")..".txt","r")
		if file==nil then
			file:close()
			local file=io.open("sys/lua/chars/"..player(id,"usgn")..".txt","w")
			file:write("")
			file:close()
		else
			inventory[id]=file:read("*all")
			file:close()
		end
	end
end

addhook("spawn","le_crzy_code")
function le_crzy_code(id)
	if inventory[id]~="" then
		timer(1000,"amazing_timer",tostring(id))
		return inventory[id]
	end
end

function amazing_timer(id)
	inventory[tonumber(id)]=""
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview