Forum

> > CS2D > Scripts > Admin no ban , don't work
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Admin no ban , don't work

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Admin no ban , don't work

superpegamento
User Off Offline

Zitieren
does not work, it can be?

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
adminlist = {122461} 

-- NO / BAN

function string.split(split,pat)
     local t = {}
     for item in string.gmatch(split, pat) do
          table.insert(t,item)
     end
     return t
end

function checkban(cmd)
     local cmdt=string.split(cmd,"(%S*)")
     if cmdt[1]:sub(1,3)=="ban" then
          local param
          if cmdt[1]=="banip" then
               param="ip"
          elseif cmdt[1]=="banname" then
               param="name"
          elseif cmdt[1]=="banusgn" then
               param="usgn"
          end
          for _,a in pairs(adminlist) do
               if player(a,param)==cmdt[2] then
                    return true
               end
          end
     end
     return false
end

addhook("parse","cantbanadmins1")
addhook("rcon","cantbanadmins2")
function cantbanadmins1(cmd)
     if checkban(cmd) then
          return 2
     end
end
function cantbanadmins2(cmd)
     if checkban(cmd) then
          return 1
     end
end

Thanks

Admin/Mod Kommentar

Don't add capital letters in every word, is considered childish. Fixed. /user GeoB99

alt Re: Admin no ban , don't work

GeoB99
Moderator Off Offline

Zitieren
Banning players with RCon only works if you typed the correct password in order to get the required privileges. There aren't any kind of bugs that are RCon related to prevent its functionality so that's an issue made by you.

As for the script, I tested it and encountered an error which is caused by the 25 line. Understanding and troubleshooting this problem is quite self-explanatory. cs2d lua cmd player has two parameters in the bracket yet param is undefined. You must add two quotes inside of param word as it should look below:
1
if player(a, "param") == cmdt[2] then

alt Re: Admin no ban , don't work

RIP-HereRestsPlookerbooy
BANNED Off Offline

Zitieren
user GeoB99 You're accually not right because the meaning of param value is that code
1
2
3
4
5
6
7
8
local param
if cmdt[1] == "banip" then
   param="ip"
elseif cmdt[1] == "banname" then
   param="name"
elseif cmdt[1] == "banusgn" then
   param="usgn"
end

user superpegamento Maybe that will make 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
adminlist = {122461}

function totable(t,match)
	local cmd = {}
	if not match then match = "[^%s]+" end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end 
	return cmd 
end

function checkban(cmd)
     local cmdt = totable(cmd,"(%S*)")
     if cmdt[1]:sub(1,3) == "ban" then
          local param
          if cmdt[1] == "banip" then
               param="ip"
          elseif cmdt[1] == "banname" then
               param="name"
          elseif cmdt[1] == "banusgn" then
               param="usgn"
          end
          for _,a in pairs(adminlist) do
               if player(a,param)==cmdt[2] then
                    return true
               end
          end
     end
     return false
end

addhook("parse","cantbanadmins")
function cantbanadmins(cmd)
	if checkban(cmd) then
		return 2
	end
end

> Remembre that rcon hook does not exists

alt Re: Admin no ban , don't work

GeoB99
Moderator Off Offline

Zitieren
@user RIP-HereRestsPlookerbooy: May I be wrong or could say better but what I meant that there's something wrong in the argument inside player() . If you attempt, for example, banning a player, it brings an error that the argument is bad or wrong thus getting a nil value (or something else). I fix the issue with possible solutions whose the error tells me.

By the way, the RCon hook exists though (see cs2d lua hook rcon).
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht