12.03.2012, 19:58
I currently do stuff like this:
Is there any better way to do? Also I noticed I couldn't do this when I tried:
If I tried doing that sscanf in the strcmp, it would just auto use amount at 0, without showing the error message. So is there any better then strcmp? If not, how could I use sscanf under strcmp?
Thanks in advance, will rep anyone who gives a valid reply =]
pawn Код:
CMD:give(playerid, params[])
{
new give[24], id, amount, string[128];
if(sscanf(params, "is[24]d", id,give,amount)) return SendClientMessage(playerid, COLOR_RED, "[SERVER] /give playerid (money/weapon) amount");
if(!strcmp(give, "money", true))
{
// money stuff
}
else if(!strcmp(give, "weapon", true))
{
// weapon stuff
}
return 1;
}
pawn Код:
CMD:give(playerid, params[])
{
new give[24], id, amount, string[128];
if(sscanf(params, "is[24]", id,give)) return SendClientMessage(playerid, COLOR_RED, "[SERVER] /give playerid (money/weapon)");
if(!strcmp(give, "money", true))
{
if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_RED, "[SERVER] /give playerid money amount");
// rest of code
}
else if(!strcmp(give, "weapon", true))
{
// weapon stuff
}
return 1;
}
If I tried doing that sscanf in the strcmp, it would just auto use amount at 0, without showing the error message. So is there any better then strcmp? If not, how could I use sscanf under strcmp?
Thanks in advance, will rep anyone who gives a valid reply =]