SA-MP Forums Archive
Simple function/include to return command paramters? - 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: Simple function/include to return command paramters? (/showthread.php?tid=245897)



Simple function/include to return command paramters? - linuxthefish - 02.04.2011

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>



Re: Simple function/include to return command paramters? - SchurmanCQC - 02.04.2011

SSCANF

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


Re: Simple function/include to return command paramters? - linuxthefish - 02.04.2011

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");