one command multiple actions. (/goto [Location] (LS LV SF)) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: one command multiple actions. (/goto [Location] (LS LV SF)) (
/showthread.php?tid=482497)
one command multiple actions. (/goto [Location] (LS LV SF)) -
Verth - 21.12.2013
I'm just searching for the 2 lines that has to be brought in.
commands:
/goto ls
/goto lv
/goto sf
I know how to make these without a space, but I would like to have them with the space.
Using ZCMD and sscanf2
Re: one command multiple actions. (/goto [Location] (LS LV SF)) -
newbie scripter - 21.12.2013
pawn Код:
CMD:goto(playerid, params[])
{
if(!strcmp("sf", params, true, 2))
{
// SF tp cmd
}
if(!strcmp("ls", params, true, 2))
{
// LS tp cmd
}
if(!strcmp("lv", params, true, 2))
{
// LV tp cmd
}
return 1;
}
Re: one command multiple actions. (/goto [Location] (LS LV SF)) - Patrick - 21.12.2013
I am using
y_stringhash & y_commands because it's easier for you, instead of using
strcmp to compare strings, nothing special in this code.
pawn Код:
YCMD:goto(playerid, params[], help)
{
if(help)
{
SendClientMessage(playerid, -1, "SF | LS | LV");
SendClientMessage(playerid, -1, "/goto [Location");
}
switch ( YHash( params ), false ) //parameter | YHash(str[], bool:sensitive = true, e_HASH_TYPE:type = bernstein);
{
case _H<LS>:
{
//ls coordinates.
}
case _H<LV>:
{
//lv coordinates.
}
case _H<SF>:
{
//sf coordinates.
}
}
return 1;
}
EDIT
Quote:
Originally Posted by newbie scripter
|
You could use that but it would not show you any message how to use the command.
Re: one command multiple actions. (/goto [Location] (LS LV SF)) -
Verth - 21.12.2013
Quote:
Originally Posted by newbie scripter
pawn Код:
CMD:goto(playerid, params[]) { if(!strcmp("sf", params, true, 2)) { // SF tp cmd } if(!strcmp("ls", params, true, 2)) { // LS tp cmd } if(!strcmp("lv", params, true, 2)) { // LV tp cmd } return 1; }
|
Those were the exact lines i needed, thanks buddy. +rep.
Quote:
Originally Posted by pds2k12
I am using y_stringhash & y_commands because it's easier for you, instead of using strcmp to compare strings, nothing special in this code.
pawn Код:
YCMD:goto(playerid, params[], help) { if(help) { SendClientMessage(playerid, -1, "SF | LS | LV"); SendClientMessage(playerid, -1, "/goto [Location"); } switch ( YHash( params ), false ) //parameter | YHash(str[], bool:sensitive = true, e_HASH_TYPE:type = bernstein); { case _H<LS>: { //ls coordinates. } case _H<LV>: { //lv coordinates. } case _H<SF>: { //sf coordinates. } }
return 1; }
EDIT
You could use that but it would not show you any message how to use the command.
|
Thanks for the assistance,
+rep