Forum

> > CS2D > Scripts > Kick Say Function!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Kick Say Function!

17 replies
To the start Previous 1 Next To the start

old Kick Say Function!

Dovahkin
User Off Offline

Quote
Guys i need help with a say function,example when you say !kick 2 and then the id 2 is kicked...

How?

1
!kick 2

Thanks sir's!

old Re: Kick Say Function!

Geez
GAME BANNED Off Offline

Quote
Do it this way:
More >


or with USGN admins (change xxxxx to your USGN ID)

More >
edited 1×, last 18.04.11 03:05:35 pm

old Re: Kick Say Function!

Banaan
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("say", "KickAPlayer")

function KickAPlayer(id, txt)
	if txt:lower():sub(1, 5) == "!kick" then
		local PlayerToKick = tonumber(txt:sub(6))
		if player(PlayerToKick, "exists") then
			parse("kick " .. PlayerToKick)
		end
	end
end

WARNING!!!
This functions allows every player to kick any player! Implement some further identity checking to make sure the player saying

1
!kick 2
actually has the right to kick that player.

I also advise to return 1 so it doesn't show up between the chat. Add

1
return 1
for that.

It's up to you to figure out how it works and how it can be improved. The best way to learn is through examples.

old Can

Dovahkin
User Off Offline

Quote
Can Ban work or Slap?

old Re: Kick Say Function!

Banaan
User Off Offline

Quote
Of course, just edit the txt and the parameter passed to the parse function. For ban:

1
parse( "banip " .. player( PlayerToKick, "ip" ) )
or
1
parse( "banname " .. player( PlayerToKick, "name" ) )
or
1
2
3
if player( PlayerToKick, "usgn" ) ~= 0 then
	parse("banusgn " .. player( PlayerToKick, "usgn") )
end

For slap:

1
parse( "slap " .. PlayerToKick )


Remember to change the txt which is needed!

old Wow

Dovahkin
User Off Offline

Quote
Your the best!

1
Banaan

old Re: Kick Say Function!

cs2dthailand
User Off Offline

Quote
How to combine this script and say kick function?

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
Admin_Table = {23450}
RGBCLR = "255255255" -- Color for saying.

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

addhook("say","adminsay")
function adminsay(id,txt)
     if txt == "rank" then
          return 0
     end
     if string.sub(txt,1,4) == "@say" then
          txt = string.sub(txt,6)
          if table.find(Admin_Table,player(id,"usgn")) then
               msg("©"..RGBCLR..player(id,"name").." (Admin): "..txt)
               return 1
          end
     end
end

Credit:Original lua is Starkkz
edited 3×, last 19.04.11 07:04:09 pm

old Cs2dth

Dovahkin
User Off Offline

Quote
heres your 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
Admin_Table = {23450}
RGBCLR = "255255255" -- Color for saying.

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

addhook("say","adminsay")
function adminsay(id,txt)
if txt == "rank" then
return 0
end
if string.sub(txt,1,4) == "@say" then
txt = string.sub(txt,6)
if table.find(Admin_Table,player(id,"usgn")) then
msg("©"..RGBCLR..player(id,"name").." (Admin): "..txt)
return 1
end
end
end

addhook("say", "KickAPlayer")

function KickAPlayer(id, txt)
     if txt:lower():sub(1, 5) == "!kick" then
          local PlayerToKick = tonumber(txt:sub(6))
          if player(PlayerToKick, "exists") then
               parse("kick " .. PlayerToKick)
          end
     end
end

old @Five

cs2dthailand
User Off Offline

Quote
ahhh,thanks for help and sorry for my failed question.

I mean If player is an admin (use Admin_Table to check)they can say !kick but your code that you give me that everyone can kick each other.


Sorry for bad English

old There cs2dth!

Dovahkin
User Off Offline

Quote
here we go

1
2
3
4
5
6
7
8
9
10
11
12
addhook("say", "KickAPlayer")

function KickAPlayer(id, txt)
if txt:lower():sub(1, 5) == "!kick" then
local PlayerToKick = tonumber(txt:sub(6))
if table.find(Admin_Table,player(id,"usgn")) then
if player(PlayerToKick, "exists") then
parse("kick " .. PlayerToKick)
end
end
end
end

done?

old @cs2dth

Starkkz
Moderator Off Offline

Quote
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 = {}
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

I think is better to make one say hook and a function with two conditionals..

old Re: Kick Say Function!

cs2dthailand
User Off Offline

Quote
If I want to add new rank like Mod and other
what should I do?(Really last question on this script)

Spoiler >

old Re: Kick Say Function!

TimeQuesT
User Off Offline

Quote
why do you add for every sayfunction it's own hook?
It's senseless just hook onefunction that calls the other. like:

1
2
3
4
5
6
adddhook ("say","say")
function say(txt,p)
say2(txt,p)
say3(txt,p)
say4(txt,p)
end

totopic:
you have to add a new table and a new condition in the "say function" that checks if the player who wrote is in the table.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview