Strtok Help!
#1

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?
Reply
#2

Which lines are the error lines?
Reply
#3

pawn Код:
221:    cmd = strtok(cmdtext, idx);
225:  tmp = strtok(cmdtext, idx);
Reply
#4

Anyone gonna help?
Reply
#5

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.
Reply
#6

Im not too keen on ZCMD
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)