Forum

> > CS2D > Scripts > Using commands in chat with "!"
Forums overviewCS2D overview Scripts overviewLog in to reply

English Using commands in chat with "!"

9 replies
To the start Previous 1 Next To the start

old Using commands in chat with "!"

KidJony
User Off Offline

Quote
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 comment

"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

old Re: Using commands in chat with "!"

Happy eyes
User Off Offline

Quote
user KidJony has written
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.

old Re: Using commands in chat with "!"

MikuAuahDark
User 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
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
edited 1×, last 07.09.12 12:31:29 pm

old Re: Using commands in chat with "!"

Zins
User Off Offline

Quote
user KidJony has written
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 ?

old Re: Using commands in chat with "!"

Infinite Rain
Reviewer Off Offline

Quote
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

old Thanks

KidJony
User Off Offline

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

For New Lua Script
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview