Forum

> > CS2D > Scripts > Kick Say Function!
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Kick Say Function!

17 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Kick Say Function!

Dovahkin
User Off Offline

Zitieren
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!

alt Re: Kick Say Function!

Geez
GAME BANNED Off Offline

Zitieren
Do it this way:
Mehr >


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

Mehr >
1× editiert, zuletzt 18.04.11 15:05:35

alt Re: Kick Say Function!

Banaan
User Off Offline

Zitieren
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.

alt Can

Dovahkin
User Off Offline

Zitieren
Can Ban work or Slap?

alt Re: Kick Say Function!

Banaan
User Off Offline

Zitieren
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!

alt Wow

Dovahkin
User Off Offline

Zitieren
Your the best!

1
Banaan

alt Re: Kick Say Function!

cs2dthailand
User Off Offline

Zitieren
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
3× editiert, zuletzt 19.04.11 19:04:09

alt Cs2dth

Dovahkin
User Off Offline

Zitieren
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

alt @Five

cs2dthailand
User Off Offline

Zitieren
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

alt There cs2dth!

Dovahkin
User Off Offline

Zitieren
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?

alt @cs2dth

Starkkz
Moderator Off Offline

Zitieren
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..

alt Re: Kick Say Function!

cs2dthailand
User Off Offline

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

Spoiler >

alt Re: Kick Say Function!

TimeQuesT
User Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht