Forum

> > CS2D > Scripts > How to make administrator commands
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to make administrator commands

3 replies
To the start Previous 1 Next To the start

old How to make administrator commands

baRD
User Off Offline

Quote
Ive been searching "how to make admin commands like !kick [plr_id]" but i cant see it anywhere so i made this thread,if someone can explain me how to make that kind of stuffs pls reply thanks!...

Admin/mod comment

"Command" is a very bad generic title. Changed. /user GeoB99

old Re: How to make administrator commands

Talented Doge
User Off Offline

Quote
Can you please do a simple thing, which is really simple that almost anyone can do it, if they are not lazy: SEARCH.

There are already plenty of examples that utilizes the say hook for commands, why do you not go to do a search?

Oh, don't make me wrong, did you search with words like "how to make admin commands like !kick [plr_id]" or "admin commands like !kick [plr_id]"? If this is your case, learn how to search first.

old Re: How to make administrator commands

cs2d_is_a_Gem
User Off Offline

Quote
@user baRD: use this code.
Goodnight

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
Admin_Table = {160589}
RGBCLR = "255255255"

function table.find(tab,val)
     for k, v in pairs(tab) do
          if v == val then
               return k
          end
     end
     return false
end

function isAdmin(id)
     return table.find(Admin_Table,player(id,"usgn"))
end

function string:split(b)
     local cmd = {}
     if type(self) == "string" then
     if not b then match = "[^%s]+" else match = "[^"..b.."]+" end
     for word in string.gmatch(self,match) do
               table.insert(cmd,word)
          end
     end
     return cmd
end

addhook("say","onSay")
function onSay(id,txt)
     if txt == "rank" then
          return 0
     end
     local s = txt:split()
     if s[1] == "@say" then
          txt = string.sub(txt,6)
          if isAdmin(id) then
               msg("©"..RGBCLR..player(id,"name").." (Admin): "..txt)
               return 1
          end
     elseif s[1] == "!kick" then
          local pl = tonumber(s[2])
          if pl and player(pl,"exists") then
               parse('kick '..pl)
          end
          return 1
     end
end

Fixed!
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview