Simple function/include to return command paramters?
#1

Has someone made/could make a include of function to return command parameters? I always have and always will find sscanf to confusing!
I'm not really sure how to explain this, but here is a example!

pawn Код:
CMD:healplayer(playerid, params[])
{
    SetPlayerHealth(p1, 100.0); //so you type "/healplayer 2" and it heals player 2...
    return 1;
}
Where p1 stands for the first parameter, and p2 stands for the seconds parameter.

pawn Код:
CMD:sethealth(playerid, params[])
{
    SetPlayerHealth(p1, p2); //so you type "/healplayer 2 50" and it sets player 2's health to 50%
    return 1;
}
And you can add it to your script using something like this, or whatever the include is called!

pawn Код:
#include <params>
Reply
#2

SSCANF

Edit: lol just learn how to use sscanf, cause theres no other way
Reply
#3

Is there any way so i don't have to type this in when i want to make a new command?

pawn Код:
new id;
if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\"");
else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)