Strtok Help! - 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)
+--- Thread: Strtok Help! (
/showthread.php?tid=320460)
Strtok Help! -
Sal - 23.02.2012
Im having some problems with strtok
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/kick", true) == 0)
{
new tmp[128];
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /kick [playerid]");
Kick(strval(tmp));
return 1;
}
return 0;
}
but it gives two errors
pawn Код:
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(221) : error 047: array sizes do not match, or destination array is too small
C:\Users\Jeremy.Jeremy-HP\Desktop\Games\Server\gamemodes\script1.pwn(225) : error 047: array sizes do not match, or destination array is too small
Help?
Re: Strtok Help! -
JhnzRep - 23.02.2012
Which lines are the error lines?
Re: Strtok Help! -
Sal - 23.02.2012
pawn Код:
221: cmd = strtok(cmdtext, idx);
225: tmp = strtok(cmdtext, idx);
Re: Strtok Help! -
Sal - 23.02.2012
Anyone gonna help?
Re: Strtok Help! -
JhnzRep - 23.02.2012
Uhh, I don't really use strcmp so I have no idea. Also please do not bump more than every 48 hours.
If you want I can make you this command in ZCMD, and explain it.
Re: Strtok Help! -
Sal - 23.02.2012
Im not too keen on ZCMD
Re: Strtok Help! -
MP2 - 23.02.2012
Stop using deprecated old functions and use ZCMD and sscanf. Who on earth still uses strcmp and strtok?!
As for your error, it needs to be 256 cells. However, I
strongly encourage you to use sscanf.