Forum

> > CS2D > Scripts > Using commands in chat with "!"
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Using commands in chat with "!"

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Using commands in chat with "!"

KidJony
User Off Offline

Zitieren
Can SomeOne can give me some commands for add in my server
Like !rs command for resetscore
and !b command for !broadcast say every 1 sec
etc...

Thanks.

Admin/Mod Kommentar

"Can SomeOne give me ..." give what? Leaving the most important part of the title away? Seriously? Did a random fucking zombie eat your stupid brain or what? Fixed! /DC

alt Re: Using commands in chat with "!"

Happy eyes
User Off Offline

Zitieren
user KidJony hat geschrieben
Can SomeOne can give me some commands for add in my server
Like !rs command for resetscore
and !b command for !broadcast say every 1 sec
etc...

Thanks.


Use admin script.... Im too lazy to write how bad you are because asking of things already scripted and uploaded millions times ago.

alt Re: Using commands in chat with "!"

MikuAuahDark
User 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
commands = {
	{
		cmd = "say",
		script = function(id,...)
			local args = {...}
			msg(id,string.char(169).."255255255"..os.date("%H:%M:%S").." "..player(id,"name")..": "..table.concat(args))
		end,
	},
}

addhook("say","yellcmd")
function yellcmd(id,txt)
	if txt:sub(1,1)=="!" then
		cmdd = false
		argument = {}
		for word in string.gmatch(txt,"[^%s]+") do
			table.insert(argument,word)
		end
		for n,v in pairs(commands) do
			if txt:sub(2,#v.cmd)==v.cmd then
				cmdd=true
				v.script(id,unpack(argument))
			end
		end
		if cmdd==false then msg2(id,string.char(169).."255000000Unknown Command!")
		end
		return 1
	end
end
the code above is used by RL Roleplay Citylife. it's easy to add command just add
1
2
3
4
{
	cmd = "<cmdname>",
	script = function(id,<another argument>) end,
},
before the end of table
EDIT: Forgot something on code, thanks to user Infinite Rain's code because it remind me
1× editiert, zuletzt 07.09.12 12:31:29

alt Re: Using commands in chat with "!"

Zins
User Off Offline

Zitieren
user KidJony hat geschrieben
Can SomeOne can give me some commands for add in my server
Like !rs command for resetscore
and !b command for !broadcast say every 1 sec
etc...

Thanks.

u want to get ideas for commands or u want the lua ready ?

alt Re: Using commands in chat with "!"

Infinite Rain
Reviewer Off Offline

Zitieren
First of all you need special string function:

1
2
3
4
5
6
7
function StrToTable(str)
	local tbl = {}
	for word in string.gmatch("[%S]+") do
		table.insert(tbl, word)
	end
	return tbl
end

After that you must program the commands

1
2
3
4
5
6
7
addhook('say', 's')
function s(id, text)
	local tbl = StrToTable(text)
	if tbl[1] == "!die" then
		parse('killplayer '.. id)
	end
end

easy

alt Thanks

KidJony
User Off Offline

Zitieren
Thanks For Users Replyed With a Code
I don't want Lua Script Already Ready i Just want Codes

For New Lua Script
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht