04.09.2011, 13:42
Quote:
So here is my code. What i'm trying to do is, when player types /bomb plant, it shows "You typed 'plant'".
But when the player typed /bomb defuse, it shows "You typed 'defuse'". Can anyone please help me? Код:
dcmd_bomb(playerid,params[]) { new tmp[256], Index; new plant, defuse; tmp = strtok(params,Index); if(!strlen(params)) return SendClientMessage(playerid,GREY,"ERROR: /bomb [plant/defuse]"); if(strlen(tmp) == defuse) { SendClientMessage(playerid, GREY, "You typed 'defuse'"); return 1; } if(strlen(tmp) == plant) { SendClientMessage(playerid, GREY, "You typed 'plant'"); return 1; } return 1; } |
pawn Код:
dcmd_bomb(playerid,params[])
{
if(!strlen(params)) return SendClientMessage(playerid,GREY,"ERROR: /bomb [plant/defuse]");
if(!strcmp(params, "defuse", true))
{
SendClientMessage(playerid, GREY, "You typed 'defuse'");
}
else if(!strcmp(params, "plant", true))
{
SendClientMessage(playerid, GREY, "You typed 'plant'");
}
return 1;
}
https://sampwiki.blast.hk/wiki/Strcmp
https://sampwiki.blast.hk/wiki/Strlen
I also suggest you start up from the beginning with the PAWN documentation:
http://www.compuphase.com/pawn/pawn.htm