SA-MP Forums Archive
Strange thing. - 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: Strange thing. (/showthread.php?tid=270082)



Strange thing. - iGetty - 19.07.2011

pawn Код:
CMD:signcheck(playerid, params[])
{
  if(!strlen(params[11]))
  {
    SendClientMessage(playerid, 0xFF0000AA, "{FFFFFF}Use: /signcheck [checknumber]");
    return 1;
  }
  new number = strval(params[11]);
  if(number == CheckNumber[playerid])
  {
    SendClientMessage(playerid, 0x00FF00AA, "{FFFFFF}You received your money!");
    GivePlayerMoney(playerid, -111);
  }
  else
  {
    SendClientMessage(playerid, 0xFF0000AA, "{FF3300}Wrong checknumber!");
  }
  return 1;
}
When I have the number, it comes up with this:

Use: /signcheck [checknumber]

Instead of the actual thing, any ideas?


AW: Strange thing. - Meta - 19.07.2011

why do you use params[11] ?
Delete the "11"


Re: Strange thing. - Calgon - 19.07.2011

zcmd or ycmd don't work the way that strtok and strcmp do in OnPlayerCommandText. The command is removed from 'params', so 'params' only contains what was typed after the command. Also, you need to do an isnull check, not an strlen check.

pawn Код:
CMD:signcheck(playerid, params[]) {
    if(isnull(params))
        return SendClientMessage(playerid, 0xFF0000AA, "{FFFFFF}Use: /signcheck [checknumber]");

    new
        iNumber = strval(params);

    if(iNumber == CheckNumber[playerid]) {
        SendClientMessage(playerid, 0x00FF00AA, "{FFFFFF}You received your money!");
        GivePlayerMoney(playerid, -111);
    }
    else return SendClientMessage(playerid, 0xFF0000AA, "{FF3300}Wrong checknumber!");
   
    return 1;
}