Please tell me how to make some command
Forum
CS2D Scripts How to make some commandHow to make some command
6 Antworten 1
Please tell me how to make some command
http://cs2d.com/help.php
Please, really, do not start a new thread before you have ever searched.
1
2
3
4
5
6
2
3
4
5
6
addhook("say","say_cmd") function say_cmd(id,t) 	if t:sub(1,4) == "!cmd" then 		msg2(id,"You called a command") 	end end
Not necessarily for say hook, can be in console too. That's a simple way when you don't want to make complicated commands and just a few of them.
Unless if you just implement few things such as 3 commands, you're freely to use string.sub(). Here you can find further information and instructions about it below:
[Tip] Stop using string.sub() for commands
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local function split(s, d) 	local w = {} 	 	s:gsub(("[^%s]+"):format(d or " "), function(v) 		w[#w + 1] = v 	end) 	 	return w end function sayhook(i, t) 	local c = t:match("^([!|@][%w]+)[%s]?") 	local d = t:match("[%s](.*)") 	 	if (c and d) then 		-- This is the place where you add commands 		if (c == "kill") then 			-- This is not error-safe due to no checkup for the arguments' type (d) 			parse(("killplayer %d"):format(tonumber((split(d))[1]))") 		end 	end end addhook("say", "sayhook")
1× editiert, zuletzt 03.04.16 12:50:02
1