SA-MP Forums Archive
Example of command with params? (newbie) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Example of command with params? (newbie) (/showthread.php?tid=275841)



Example of command with params? (newbie) - TheBetaFox - 11.08.2011

hi!

This is not my Acc, I just asked my friend to let me use his Computer so I could ask this Question.

I'm using YCMD (latest public Version), and I'd like an example of a command with params in a fashion like:
/stunt 1
/stunt 2
And so on. If it matters, I have 60 Teleports which I have to include (scary).

Please help.
Thank you.


Re: Example of command with params? (newbie) - Darnell - 11.08.2011

I suggest using zCMD, easier.
pawn Код:
CMD:stunt 1(playerid, params[])
{
    SetPlayerPos(playerid,X,Y,Z);
        return 1;
    }
    return 0;
}



Re: Example of command with params? (newbie) - TheBetaFox - 11.08.2011

Quote:
Originally Posted by Darnell
Посмотреть сообщение
I suggest using zCMD, easier.
pawn Код:
CMD:stunt 1(playerid, params[])
{
    SetPlayerPos(playerid,X,Y,Z);
        return 1;
    }
    return 0;
}
Hi, this is TheBetaFox. My friend 'ere is gone.
The ZCMD-based YCMD wouldn't make much more of a difference.

pawn Код:
YCMD:stunt 1(playerid, params[], help)
{
    #pragma unused params
    if(help)
    {
        SendClientMessage(playerid, -1, "Help text goes here for /help stunt 1");
    }
    SetPlayerPos(playerid,X,Y,Z);
    return 1;
}
I added the if(help) because I love that function of YCMD. /help [command] has been a function that I've seen requested on various stunt servers, so I've thought that it might help people understand what X command does ~ but instead of adding help to 'ambiguous' commands, I'm adding a help section to all commands.

But I'm not looking for simply naming commands 'stunt 1' 'stunt 2'.
I want to consider the number as a parameter, include everything in one command. Basically something like if parameter = 1 do this, if parameter = 2 do that, and so on.

I'm also using the SSCANF2 plugin, so if using SSCANF helps to speed up things, use it.

...I'm not a very good scripter, and I have no idea either, just like my friend. This has sparked my curiosity and I am awaiting for a new, more helpful reply.

-TheBetaFox


Re: Example of command with params? (newbie) - MadeMan - 11.08.2011

pawn Код:
YCMD:stunt(playerid, params[], help)
{
    if(help)
    {
        SendClientMessage(playerid, -1, "Help text goes here for /help stunt 1");
        return 1;
    }
    if(strcmp(params, "1", true) == 0)
    {
        SetPlayerPos(playerid,X,Y,Z);
    }
    else if(strcmp(params, "2", true) == 0)
    {
        SetPlayerPos(playerid,X,Y,Z);
    }
    else
    {
        SendClientMessage(playerid, -1, "Unknown parameter");
    }
    return 1;
}



Re: Example of command with params? (newbie) - TheBetaFox - 11.08.2011

Thank you, MadeMan.
+1 rep