Forum

> > CS2D > Scripts > Using '/'
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Using '/'

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Using '/'

andrew65952
User Off Offline

Zitieren
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

alt Re: Using '/'

sonkii
User Off Offline

Zitieren
I think you can use aliases or


1
if checkSay=="/setspeed" then

Not tested.It should work.

Use alias.

alt Re: Using '/'

Nekomata
User Off Offline

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

alt Re: Using '/'

Waldin
User Off Offline

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

alt Re: Using '/'

Mora
User Off Offline

Zitieren
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

alt Re: Using '/'

Baloon
GAME BANNED Off Offline

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

alt Re: Using '/'

GeoB99
Moderator Off Offline

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