strtok?
#10

The easiest way is zcmd + sscanf:

pawn Код:
COMMAND:ban(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
      new targetid;
      if(sscanf(params,"u",targetid)) SendClientMessage(playerid,0xFFFFFF,"/ban playerid reason");
      else if(targetid == INVALID_PLAYER_ID) SendClientMessage(playerid,0xFFFFFF,"Invalid player ID");
      else
      {
          SendClientMessage(playerid,0xFFFFFF,"Player banned");
          Ban(targetid);
      }
    }
    else SendClientMessage(playerid,0xFFFFFF,"You are not admin");
    return 1;
}
Using strval to get player ID is bad way since iif you write anything instead of type integer it will return 0 and innocent palyer will be banned. Use ReturnUser or sscanf instead.

And DCMD is just command processor (like zcmd) and has nothing to do with strtok. As replacement for strtok you can use sscanf.
Reply


Messages In This Thread
strtok? - by waza75 - 06.01.2010, 16:20
Re: strtok? - by ¤Adas¤ - 06.01.2010, 16:25
Re: strtok? - by ClanDBZVegeta - 06.01.2010, 16:33
Re: strtok? - by waza75 - 06.01.2010, 16:34
Re: strtok? - by waza75 - 06.01.2010, 17:06
Re: strtok? - by Striker_Moe - 06.01.2010, 17:08
Re: strtok? - by waza75 - 06.01.2010, 17:24
Re: strtok? - by Striker_Moe - 06.01.2010, 17:27
Re: strtok? - by waza75 - 06.01.2010, 17:31
Re: strtok? - by Sergei - 06.01.2010, 17:38

Forum Jump:


Users browsing this thread: 1 Guest(s)