Forum

> > CS2D > Scripts > how to stop 2 usgn login
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch how to stop 2 usgn login

52 Antworten
Seite
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang

alt Re: how to stop 2 usgn login

Avo
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
addhook('join', 'JoinHook')
function JoinHook(id)
     for _,ID in pairs(player(0,"table")) do
          if player(ID,"usgn")== player(id, 'usgn') and ID~=id then
               timer(500,"parse","kick "..id.." \"Two players with the same USGN number are not allowed to play!\"")
          end
     end
end

EDIT: @user EP: I thought about it, but you were first, damn you . My is shorter
1× editiert, zuletzt 06.07.12 19:13:52

alt Re: how to stop 2 usgn login

Infinite Rain
Reviewer Off Offline

Zitieren
1
2
3
4
5
6
7
8
addhook('join', 'JoinHook')
fuction JoinHook(id)
	for n, w in pairs(player(0, 'table')) do
		if player(id, 'usgn') ~= 0 and player(id, 'usgn') == player(w, 'usgn') then
			timer(100, 'parse', 'kick '..id) 
		end
	end
end

alt Re: how to stop 2 usgn login

EP
User Off Offline

Zitieren
Added IP detection:
1
2
3
4
5
6
7
8
addhook("join","usgns")
function usgns(id)
	for _,i in ipairs(player(0,"table")) do
		if id ~= i and (player(i,"usgn") == player(id,"usgn") or player(i,"ip") == player(id,"ip")) then
			timer(100,"parse","kick "..id)
		end
	end
end

alt Re: how to stop 2 usgn login

Apache uwu
User Off Offline

Zitieren
Isn't it just:

1
2
3
4
5
6
7
8
addhook("join","_join")
function _join(id)
	for _,i in pairs(player(0,"table")) do
		if id~=i and player(i,"usgn")==player(id,"usgn") and player(i,"usgn")~=0 or player(i,"ip")==player(id,"ip") then
			timer(300,"parse","kick "..id)
		end
	end
end

ipairs is slower than pairs simply because it sorts it by index -- while pairs does not.

You should also add another check for no usgn (0), because if there are 2 people with no usgn they should still be able to join.

And lastly, 100 ms is still too little for the kick message to show on some systems. I increased it to 300.

alt Re: how to stop 2 usgn login

omg
User Off Offline

Zitieren
might as well increase the timer to 1000 ms, actually. their being in the server doesnt really matter until they do something (?) im guessing

alt Re: how to stop 2 usgn login

KimKat
GAME BANNED Off Offline

Zitieren
user Avo hat geschrieben
Me not o_O.

I rund CS2D, start lan server, join.

I run the second window of CS2D, join previous server, and then it kicks the second player.
My script does the same, but I just forgot to write in the kick part.

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
_Parr={}
function in_table(t,k)
	for key, v in pairs(k) do
		if _Parr[v] then
			if v == t then return true end
		end
		_Parr[v] = key
	end
	return false
end
function show_table(t)
	for k, v in pairs(t) do
		print(k,v)
	end
end
addhook("join","on_join")
function on_join(p)
	local _P={[1]=player(p,"exists"),[2]=player(p,"name")}
	local rsn={[1]=" has the same U.S.G.N. as another player in the server.",[2]="Duplicated U.S.G.N. ID detected!"}
	local U_ID=player(p,"usgn")
	if (_P[1]) then
		-- Player exist.
		parse("sv_msg ©102255102Player ".._P[2].." exist.")
		if (U_ID~=nil or U_ID~=0 and U_ID==in_table(_Parr,U_ID)) then
			-- Player has a U.S.G.N. ID of 1 or higher.
			-- The script will insert the player U.S.G.N. ID into players table.
			parse("sv_msg ©090090090".._P[2].." (ID: #"..p..", U.S.G.N. ID: #"..U_ID..") joined the game!")
			parse("sv_msg ©255102102".._P[2]..rsn[1].."")
			parse("kick "..p.." "..rsn[1])
		elseif (U_ID==(not in_table(_Parr,U_ID))) then
			-- Player U.S.G.N. is not in table.
			table.insert(_Parr,U_ID)
			parse("sv_msg ©135135135".._P[2].." (ID: #"..p..", U.S.G.N. ID: #"..U_ID..") joined the game and is now registered with the server for the first time!")
		elseif (U_ID==0 or U_ID==nil) then
			-- Guest player with U.S.G.N. ID of (#0).
			parse("sv_msg ©096096096You're playing as a guest.")
		end
	elseif (_P==false) then
		-- Player doesn't exist.
		parse("sv_msg ©255102102Player ".._P[2].." doesn't exist.")
	end
end
addhook("spawn","on_spawn")
function on_spawn(p)
	local _P={[1]=player(p,"exists"),[2]=player(p,"name")}
	if (_P[1]) then
		parse('hudtxt2 '..p..' 1 "©102255102You joined as '.._P[2]..'!" 290 22 0')
	end
end
See if this works or not, I'm trying to perfect it. I'm basically checking if there is a U.S.G.N. ID in the table, if there isn't then the player who are joining the game will be allowed to stay on the server. However if there already is a U.S.G.N. ID in the table the player will get kicked with a reason as supplied in the Lua script. If there is player's without U.S.G.N. ID's then it'll just skip the check and allow them to play. Hope it works out for you, I think it worked out fine for me.

Ah man, it seems to kick anyone who joins server. Because the U.S.G.N. ID is added and it checks for the U.S.G.N. ID. However if someone manages to work this out, the script will work just fine.
2× editiert, zuletzt 07.07.12 01:19:12

alt Re: how to stop 2 usgn login

Ariiel
User Off Offline

Zitieren
user KimKat hat geschrieben
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
_Parr={}
rsn={"has the same U.S.G.N. as another player in the server.","Duplicated U.S.G.N. ID detected!"}
function in_table(t,k)
     for _,v in pairs(k) do
          if(_Parr[v] ~= nil) then
               if (v==t) then return true end
          end
          _Parr[v] = _
     end
     return false
end
addhook("join","on_join")
function on_join(p)
     local U_ID=player(p,"usgn")
     local _P={[1]=player(p,"exists"),[2]=player(p,"name")}
     if (_P[1]) then
          -- Player exist.
          parse("sv_msg ©102255102Player ".._P[2].." exist.")
          if (U_ID~=nil or U_ID~=0 and U_ID==in_table(_Parr,U_ID)) then
		-- Player has a U.S.G.N. ID of 1 or higher and already exists in the table, therefor initialize the kick process.
		parse("sv_msg ©255102102".._P[2].." "..rsn[0])
		parse("kick "..p.." "..rsn[1])
          elseif (U_ID==(not in_table(_Parr,U_ID))) then
               -- Player U.S.G.N. is not in table.
               table.insert(_Parr,U_ID)
                  parse("sv_msg ©135135135".._P[2].." (ID: #"..p..", U.S.G.N. ID: #"..U_ID..") joined the game and is now registered with the server for the first time!")
          elseif (U_ID==0 or U_ID==nil) then
		-- Guest player with U.S.G.N. ID of (#0).
		parse("sv_msg ©096096096".._P[2].." is playing as a guest.")
          end
     elseif (_P==false) then
          -- Player doesn't exist.
          parse("sv_msg ©255102102Player ".._P[2].." doesn't exist.")
     end
end
See if this works or not


No, this not work don't kick the usgn repeated
Zum Anfang Vorherige 1 2 3 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht