Forum

> > CS2D > Scripts > Using '/'
Forums overviewCS2D overview Scripts overviewLog in to reply

English Using '/'

6 replies
To the start Previous 1 Next To the start

old Using '/'

andrew65952
User Off Offline

Quote
Is there anyway to make a custom command that uses / in scripts?
I have made a command called setspeed (-100-100) and It looks ugly showing in chat... is there anyway to make it work with a / in front of it ex. /setspeed

1
2
3
4
5
6
7
8
addhook("say","speedchanger")
function speedchanger(id,message)
checkSay = string.sub(message, 1, 8 )
if checkSay=="setspeed" then
newSpeed = string.sub(message, 9, 13)
parse("speedmod "..id..newSpeed)
end
end

old Re: Using '/'

sonkii
User Off Offline

Quote
I think you can use aliases or


1
if checkSay=="/setspeed" then

Not tested.It should work.

Use alias.

old Re: Using '/'

Nekomata
User Off Offline

Quote
You can't. Use other command prefixes such as ! Or @. They're pretty common ones.
@setspeed, !setspeed

old Re: Using '/'

Waldin
User Off Offline

Quote
What you want is parse hook, / at start in chat is like writing in console
in chat /kill is kill in console
in chat /say hello world is say hello world in console
so you need parse hook, but this just work for server.

old Re: Using '/'

Mora
User Off Offline

Quote
Use this, tested, worked.

1
2
3
4
5
6
7
8
9
10
addhook("say","speedchanger")
function speedchanger(id,txt)
	if txt:sub(1,9)=="setspeed " then
	r = tonumber(txt:sub(10))
		if r~=nil then
		parse("speedmod "..id.." "..r)
		return 1
		else msg2(id,"\169255000000Error: Wrong speed value.") return 1 end
	end
end

This will works for everyone who using command and only for himself. I can better but i think it's that what you want.

btw using
return 0
or
return 1
will show/hide your message(exactly your, with nick and ur text).
cs2d lua hook say

old Re: Using '/'

Baloon
GAME BANNED Off Offline

Quote
Would you stop creating thread and try to solve yourself? There's sample folder too, if you do want to learn basics of LUA coding. And visit http://cs2d.com/help.php for more codes.

old Re: Using '/'

GeoB99
Moderator Off Offline

Quote
The slash is a reserved symbol prefix in CS2D for CS2D commands related only therefore using it for customized Lua scripted commands won't work in any way. As user Nekomata said just use the common prefixes for your commands instead of /.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview