SA-MP Forums Archive
ZCMD/SSCANF PROBLEM - 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: ZCMD/SSCANF PROBLEM (/showthread.php?tid=130701)



ZCMD/SSCANF PROBLEM - Zeromanster - 27.02.2010

So i have this command:

pawn Код:
cmd(wanted, playerid, params[])
{
  if(IsPlayerConnected(playerid) && PlayerLoggedIn[playerid])
  {
    if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1)
    {
      new reason[32];
      new player; new wanted;
      if(sscanf(params, "uds",player,wanted,reason))
      {
        SendClientMessage(playerid, COLOR_HELP, "KORISTENJE: /wanted [ID/PartOfName] [wanted] [reason]");
        return 1;
      }
      if(strlen(reason) > 32) strdel(reason, 32, strlen(reason));
    }
  }
  return 1;
}
And when i type in a reason that's higher than 32 characters it says SERVER: Unkown command, otherwise it's fine.

I put a code underneath that checks is it higher that 32 so it deletes it to be 32 but it didn't help.

Please help, thank you.


Re: ZCMD/SSCANF PROBLEM - Nero_3D - 27.02.2010

Its so, the reason array has 32 cells (because of your entered index 32)

and when sscanf try to copy the string into the array and reaches a limit over 32 the code crash (return 0) because reason[32] is an invalid cell

if you use sscanf 1.0 you only can raise the reason string, if you use sscanf 2.0 (the plugin) you can set a size


Re: ZCMD/SSCANF PROBLEM - gotenks918 - 27.02.2010

Quote:

if(sscanf(params, "uds[128]",player,wanted,reason))

Try that.