English Admin no ban , don't work

9 replies
Goto Page
To the start Previous 1 Next To the start
22.03.16 12:45:33 am
Up
superpegamento
User
Offline Off
does not work, it can be?

Code:
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 comment:

Don't add capital letters in every word, is considered childish. Fixed. /user Fraizeraust
22.03.16 02:22:49 am
Up
Talented Doge
User
Offline Off
There is no ip called ip.
Talented Doge
22.03.16 03:19:12 am
Up
superpegamento
User
Offline Off
@user Talented Doge:
you can solve?
22.03.16 03:27:23 am
Up
Talented Doge
User
Offline Off
You haven't included the say hook, so cannot help you.
Talented Doge
22.03.16 06:57:09 pm
Up
superpegamento
User
Offline Off
@user Talented Doge:

What I wanted was unable ban from the console With the rcon
but only those who were in AdminList
22.03.16 07:39:54 pm
Up
Fraizeraust
Moderator
Offline Off
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:
Code:
1
if player(a, "param") == cmdt[2] then
22.03.16 11:18:17 pm
Up
user Fraizeraust You're accually not right because the meaning of param value is that code
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...

Code:
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
23.03.16 02:47:21 am
Up
superpegamento
User
Offline Off
this will help that can not be banned admin with cmd?
23.03.16 08:13:07 am
Up
user superpegamento Well,not it won't you need that admin USGN and IP and Name to do it...but the IP always changes when you close the modem and open it again and name is easy to change it by cs2d cmd setname so you are unable to do it.
edited 1×, last 23.03.16 08:29:22 am
23.03.16 03:27:06 pm
Up
Fraizeraust
Moderator
Offline Off
@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).
To the start Previous 1 Next To the start