Problem with sscanf - 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)
+--- Thread: Problem with sscanf (
/showthread.php?tid=458279)
Problem with sscanf -
Cypress - 15.08.2013
pawn Код:
CMD:clan(playerid, params[])
{
new option[14];
if (sscanf(params, "s[14]", option))
{
return 1; //Dialog is here
}
else if (!strcmp(option, "join", true))
{
if (sscanf(params,"u", option))
return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
}
else return 0; // Invalid parameter
return 1;
}
So if you type /clan join it will show the usage of the command. It doesn't work when I type /clan join 1 etc, can't even see the usage and it returns the invalid parameter.
Re: Problem with sscanf -
Jefff - 15.08.2013
pawn Код:
if(sscanf(params, "s[14]D(-1)", option,clanid))
then
pawn Код:
if(clanid < 0) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
Re: Problem with sscanf -
Cypress - 16.08.2013
There is another problem now.
pawn Код:
CMD:clan(playerid, params[])
{
new option[14], clanid, id;
if (sscanf(params, "s[14]D(-1)", option, clanid))
{
return 1; //Dialog is here
}
else if (!strcmp(option, "join", true))
{
if(clanid < 0) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
}
else if (!strcmp(option, "accept", true))
{
if (sscanf(params, "U(-1)", id)) SendClientMessage(playerid, -1, "usage: /clan accept <id>");
else if (id == INVALID_PLAYER_ID) return SendErrorMessage(playerid, "player not found");
}
else return 0; // Invalid parameter
return 1;
}
So there is another problem. I tried to do the same with join as with accept adding U(-1) but it doesn't work. Any ideas?
Re: Problem with sscanf -
Jefff - 16.08.2013
pawn Код:
CMD:clan(playerid, params[])
{
if(isnull(params))
{
return 1; //Dialog is here
}
if (!strcmp(params, "join", true, 4))
{
if(!params[4] || !('0' <= params[5] <= '9')) return SendClientMessage(playerid, -1, "usage: /clan join <clan id>");
new clanid = strval(params[5]);
}
else if (!strcmp(params, "accept", true, 6))
{
new id;
if (!params[6] || sscanf(params[7], "u", id)) SendClientMessage(playerid, -1, "usage: /clan accept <id>");
else if (id == INVALID_PLAYER_ID) SendErrorMessage(playerid, "player not found");
else{
}
}
else return 0; // Invalid parameter
return 1;
}