19.03.2011, 13:34
Okay, the problem is with how you're using strtok, you need to use it before the command, so you get the original part of the command, the "/part" without any of the additional parameters, so for that you need to split the information and store it earlier on before the command.
For example:
Then it should work properly when you type "/find 0", because think about what's happening now.
You type "/find", the if statement checks if cmdtext matches "/find", and it does. Then you type "/find 0", the cmdtext doesn't match "/find", because cmdtext is "/find 0". Now what we're doing is splitting up the information, so that only the first part of the command is compared.
Does this information help? It would be a lot easier if you used a command processor like DCMD, YCMD or ZCMD.
For example:
pawn Код:
public OnPlayerCommandText(playerid, params[])
{
new
idx,
cmd[128] = strtok(cmdtext, idx);
if(strcmp(cmd,"/find",true) == 0)
// your command
return 0;
}
You type "/find", the if statement checks if cmdtext matches "/find", and it does. Then you type "/find 0", the cmdtext doesn't match "/find", because cmdtext is "/find 0". Now what we're doing is splitting up the information, so that only the first part of the command is compared.
Does this information help? It would be a lot easier if you used a command processor like DCMD, YCMD or ZCMD.