ZCMD/SSCANF PROBLEM
#1

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.
Reply
#2

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
Reply
#3

Quote:

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

Try that.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)