Forum

> > CS2D > Scripts > Save data from steam users. [roleplay]
Forums overviewCS2D overview Scripts overviewLog in to reply

English Save data from steam users. [roleplay]

2 replies
To the start Previous 1 Next To the start

old Save data from steam users. [roleplay]

cs2d_is_a_Gem
User Off Offline

Quote
Hi dear forum us
How can I edit this code so that I also save the data of steam players?

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
addhook("join","rp_load")
function rp_load(id)
	rp_license[id]=0
	rp_ct[id]=false
	rp_Adminlevel[id]=0
	rp_arrest[id]=false
	player_have_pos[id]=false
	tele_x[id]=800
	tele_y[id]=200
	rp_money[id]=100
	UsgnIds[id]= 0
	rp_vipmsg[id]=0
	rp_vipaddons[id]=0
	rp_NextAddons[id]=0
	InternalFreeImage(id)
	InternalFreeAddons(id)

	local UsgnID = player(id,"usgn")
	UsgnIds[id] = 0
	if UsgnID > 0 then
		local sameusgn = false
		for ids = 1,32 do
			if ids~=id then
				if UsgnIds[ids]==UsgnID then
					sameusgn=true
					break
				end
			end
		end
		if sameusgn==false then
			rp_msg2(id,"000255000","Login with "..UsgnID)
			rp_Adminlevel[id]= isAdmin(UsgnID)
			if rp_Adminlevel[id]>0 then
				rp_ct[id]=true
				rp_license[id]=3
				SetAddons(id,1)
				rp_msg2(id,"000255000","Wellcome Admin!")
			else
				local filename = "sys/lua/role/"..UsgnID..".txt"
				local file = io.open(filename)
				if file then
					LoadUserStat(id,file)
					rp_msg2(id,"000255000","Load Successfully!")
					if file ~= nil then
						file:close()
					end
				end
			end
			UsgnIds[id] = UsgnID
		else
			rp_msg2(id,"255000000","Load fail!")
		end
	else
		rp_msg2(id,"255000000","Please register a U.S.G.N. account at http://www.unrealsoftware.de/ and make sure that you are logged in!")
		rp_msg2(id,"255000000","Your money and license not save on Database")
	end
end

function SaveUserStat(id,UsgnID)
	file = io.open("sys/lua/role/"..UsgnID..'.txt', "w+") or io.tmpfile()
	local text = ""
	text = tostring(rp_money[id])
	text = text .." "..rp_license[id]
	if rp_arrest[id]==true then
		text = text .." 1"
	else
		text = text .." 0"
	end
		
	for k, v in ipairs(Addons) do
		text = text .." "..v.FLic[id]
	end
	file:write(text)
	file:close()
end

function LoadUserStat(id,file)
	for line in file:lines() do
		local parses = totable(line)
		local userMoney=tonumber(parses[1])
		if userMoney ~= nil then
			rp_money[id]= userMoney
		end
		if (tonumber(parses[2])~=nil) then
			rp_license[id]=tonumber(parses[2])
		end
		if (tonumber(parses[3]) == 1) then
			rp_arrest[id]=true
			rp_license[id]=0
		end
		
		local counter=3
		for k, v in ipairs(Addons) do
			counter=counter+1
			local LicItem = tonumber(parses[counter])
			if LicItem~=nil then
				v.FLic[id]=LicItem
			else
				v.FLic[id]=0
			end
		end
	end
end

I read how to do it but it is very difficult for me at this moment, to achieve it since my skills in script is basic.

old Re: Save data from steam users. [roleplay]

Talented Doge
User Off Offline

Quote
You just check if the player's USGN is 0:

1. If their USGN IS 0, then go for checking Steam id.
2. If their USGN IS NOT 0, then just use their USGN's data.

Steam ID is string, so you must use ~= "0" to represent conditions of logged in to Steam.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview