Forum
CS2D Scripts Login , register & Save system ?Login , register & Save system ?
21 repliesI've been searching for something like that but i didn't find
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
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
ranking = {} prefix = "@" dir = "sys/lua/data/" addhook("say", "_s") addhook("join", "_j") function _s(p, t) 	if t:sub(1,1) == prefix then 		if t:sub(2,6) == "login" then 			local tgt = t:sub(8) 			local file = io.open(dir..tgt..".txt", "r") 			if file then 				local read1 = file:read("*l") 				ranking[p] = read1 or 0 				file:close() 				msg2(p, "\169000255000You've been logged in!") 			else 				msg2(p, "\169255000000Cannot find your account! Please register one!") 			end 		elseif t:sub(2,9) == "register" then 			local tgt = t:sub(11) 			local file = io.open(dir..tgt..".txt", "r") 			if file then 				msg2(p, "\169255000000Account with this password already exists! Please choose another one!") 			else 				local file = io.open(dir..tgt..".txt", "w") 				file:write(ranking[p]) 				file:close() 				msg2(p, "\169000255000Registeration succeed! You may now login with your password!") 			end 		end 		return 1 	end end function _j(p) 	ranking[p] = "0" end
Written this, may not be the perfect one though.
@ XoOt: Ye , like terraria servers xd..
@ Talented Doge: I tried your code , it's not what i was searching for , i want if the player didn't login then he will be in spec team always and can;t talk at all..
edited 1×, last 15.06.15 06:08:38 am
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
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
ranking = {} prefix = "@" dir = "sys/lua/data/" addhook("say", "_s") addhook("join", "_j") addhook("team", "_t") function _s(p, t) if t:sub(1,1) == prefix then if t:sub(2,6) == "login" then local tgt = t:sub(8) local file = io.open(dir..tgt..".txt", "r") if file then local read1 = file:read("*l") ranking[p] = tonumber(read1) or 0 file:close() msg2(p, "\169000255000You've been logged in!") else 				msg2(p, "\169255000000Cannot find your account! Please register one!") end elseif t:sub(2,9) == "register" then local tgt = t:sub(11) local file = io.open(dir..tgt..".txt", "r") if file then msg2(p, "\169255000000Account with this password already exists! Please choose another one!") else 				ranking[p] = 1 local file = io.open(dir..tgt..".txt", "w") file:write(ranking[p]) file:close() msg2(p, "\169000255000Registeration succeed! You may now login with your password!") end end return 1 	elseif ranking[p] < 1 then 		msg2(p, "\169255000000You must log in to say! Say !register to register if you did not register!") return 1 end end function _j(p) ranking[p] = 0 end function _t(p) 	if ranking[p] < 1 then msg2(p, "\169255000000You must log in to play! Say !register to register if you did not register!") return 1 end end
edited 3×, last 15.06.15 07:34:30 am
CS2D has a unique data however, but I don't really know how to fetch 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
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
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
-- (re)create "passwords.txt" file io.open("passwords.txt", "w"):close() logged = {} addhook("say", "sayhook") function sayhook(id, message) 	if (player(id, "usgn") > 0) then 		if (message:sub(1, 6) == "!login") then 			if (not logged[player(id, "usgn")]) then 				local file = io.open("passwords.txt", "a+") 				local password = message:sub(8, #message) 				local usgn = { 					string = tostring(player(id, "usgn")), 					wrongpassword = false 				} 				 				for line in file:lines() do 					if (line:sub(1, #usgn.string) == usgn.string) then 						if (line:sub(#usgn.string + 2, #line) == tostring(password)) then 							logged[player(id, "usgn")] = true 						else 							usgn.wrongpassword = true 							 							msg2(id, "\169255000000Wrong password!@C") 							msg2(id, "Please contact the administrator of this server!@C") 						end 						 						break 					end 				end 				 				file:close() 				 				if (not logged[player(id, "usgn")] and not usgn.wrongpassword) then 					msg2(id, "\169255000000You don't have any account!@C") 					msg2(id, "Please register via \"!register <password>\"!@C") 				elseif (logged[player(id, "usgn")]) then 					msg2(id, "You are logged in!@C") 				end 			else 				msg2(id, "\169255000000You already logged in!@C") 			end 			 			return 1 		elseif (message:sub(1, 9) == "!register") then 			local file = io.open("passwords.txt", "a+") 			local password = message:sub(11, #message) 			local usgn = { 				string = tostring(player(id, "usgn")), 				account = false 			} 			 			for line in file:lines() do 				if (line:sub(1, #usgn.string) == usgn.string) then 					usgn.account = true 					 					msg2(id, "\169255000000You already have an account!@C") 					 					if (not logged[player(id, "usgn")]) then 						msg2(id, "Please login via \"!login <password>\"!@C") 					end 					 					break 				end 			end 			 			if (not usgn.account) then 				file:write(tostring(player(id, "usgn")) .. " " .. password) 				 				msg2(id, "You can now login using your registered account!@C") 				msg2(id, "Please login via \"!login <password>\"!@C") 			end 			 			file:close() 			 			return 1 		end 	end end
''!register glix123 glix123'' and when it done you have to login ''!login glix123''. You dont need usgn, you make account in server, is that what you mean?
@ Dousea: I will test your code later..
Doesn't add ;new line; (easy to fix)
It's almost perfect, just add....
(encryptionz, some might use their 'USGN' passwords in this script)
--------------
edit: Almost forgot
Kirito2K has written
if i didn't login or register then i can't talk or move or even join a team
edited 4×, last 16.06.15 04:54:28 am
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
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
io.open("accounts.txt", "w"):close() logged = {} addhook("say", "sayhook") addhook("leave", "leavehook") function sayhook(id, message) 	if (message:sub(1, 9) == "!register" or message:sub(1, 6) == "!login") then 		local strings = {} 		 		for string in message:gmatch("[^%s]+") do 			table.insert(strings, string) 		end 		 		local arguments = select("#", unpack(strings)) 		 		if (arguments > 3 or arguments < 3) then 			msg2(id, "\169255000000Please insert username and password properly without any whitespace!@C") 			msg2(id, "Use \"<username> <password>\" structure!@C") 			 			return 1 		end 		 		local file = io.open("accounts.txt", "a+") 		 		if (message:sub(1, 9) == "!register") then 			for line in file:lines() do 				if (line:sub(1, #strings[2]) == strings[2]) then 					msg2(id, "\169255000000Account with that username already exists!@C") 					file:close() 					 					return 1 				end 			end 			 			file:write(strings[2] .. " " .. strings[3] .. "\n") 			 			msg2(id, "You can now log in using your registered account!@C") 			msg2(id, "Please log in via \"!login <username> <password>\"!@C") 		elseif (message:sub(1, 6) == "!login") then 			if (not logged[id]) then 				for line in file:lines() do 					if (line:sub(1, #strings[2]) == strings[2]) then 						if (line:sub(#strings[2] + 2, #line) == strings[3]) then 							logged[id] = true 							 							msg2(id, "Welcome, " .. strings[2] .. "!@C") 							file:close() 							 							return 1 						else 							msg2(id, "\169255000000Wrong password!@C") 							msg2(id, "Please contact the administrator of this server!@C") 							file:close() 							 							return 1 						end 					end 				end 				 				msg2(id, "\169255000000Account doesn't exist!@C") 				msg2(id, "Please register via \"!register <username> <password>\"!@C") 			else 				msg2(id, "\169255000000You already logged in!@C") 			end 		end 		 		file:close() 		 		return 1 	elseif (message:sub(1, 7) == "!logout") then 		if (logged[id]) then 			logged[id] = false 			 			msg2(id, "You are logged out!@C") 		else 			msg2(id, "You are not logged in!@C") 		end 		 		return 1 	end end function leavehook(id) 	if (logged[id]) then 		logged[id] = false 	end end
edited 1×, last 16.06.15 08:16:30 am
Tried to create long accounts but there's a limit in every line in accounts.txt
Black Wolf has written
''!register glix123 glix123'' and when it done you have to login ''!login glix123''. You dont need usgn, you make account in server, is that what you mean?
Kirito2K has written
@ Black Wolf: Yep , that what i want ://..
I was basically confused. Was he trying to answer this?
Black Wolf has written
He wants it like in cracked minecraft servers.
And what kind of limit you talked about?