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: Sscanf (
/showthread.php?tid=491508)
Sscanf -
EliteApple - 31.01.2014
pawn Код:
if(strcmp(Option, "joinrank", true) == 0)
{
if(sscanf(params, "n", RankID))
{
if(PlayerInfo[playerid][pRank] >= 2)
{
SendClientMessage(playerid, COLOR_RED, "You're not high enough to set joinrank.");
return 1;
}
format(string, sizeof(string), "[FACTION] Join rank is now set too %s.", RankID);
SendFactionMessage(faction, COLOR_LIGHTRED, string);
DynamicFactions[faction][fJoinRank] = ID;
return 1;
}
}
I'm learning ZCMD/sscanf, and this part of the code is weird, it winds up setting the join rank to like 65538 or something. When I try setting it to 7, whats wrong?
Re: Sscanf -
MP2 - 31.01.2014
While 'n' is number, people will only really be inputting integers, so you may as well change it to 'i'.
Asides from that, to get to the actual problem, 'params' includes EVERYTHING after the command, including the 'joinrank' 'sub-command'. You haven't shown the entire command so I'm not sure what it's meant to be, but for example '/set joinrank <rank>', you're passing the entire 'params' string in to sscanf, which includes the 'joinrank' part of the string.
Re: Sscanf -
Beckett - 31.01.2014
Check for 'i' not 'n'
Re: Sscanf -
SickAttack - 31.01.2014
Код:
new Option2[10];
if(strcmp(Option, "joinrank", true) == 0)
{
if(sscanf(Option2, "i", RankID))
{
if(PlayerInfo[playerid][pRank] >= 2)
{
SendClientMessage(playerid, COLOR_RED, "You're not high enough to set joinrank.");
return 1;
}
DynamicFactions[faction][fJoinRank] = RankID;
format(string, sizeof(string), "[FACTION] Join rank is now set too %s.", RankID);
SendFactionMessage(faction, COLOR_LIGHTRED, string);
return 1;
}
}