Example of command with params? (newbie)
#1

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.
Reply
#2

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

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
Reply
#4

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;
}
Reply
#5

Thank you, MadeMan.
+1 rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)