strtok, in a sense, splits a string by a delimiter. In this specific case, strtok will go through cmdtext at the index specified by idx, and when it gets to the first space, it will set idx to that location, and put the string into tmp.
With zcmd, it's not very much different, where you would be doing that in a command like this...
pawn Код:
if(strcmp(cmdtext, "/hi", true, 3) == 0)
{
new idx = 0, tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
}
In zcmd, it's very similar.
pawn Код:
CMD:hi(playerid, params[])
{
new idx = 0, tmp[128];
tmp = strtok(params, idx);
if(!strlen(tmp))
}
So it's not really too much different, as all it does is split a string into multiple strings by spaces.
Now, just a little tip, I suggest you switch to sscanf (use the search function), it will do this process a lot quicker and make it so much easier to do and read.
With sscanf + zcmd:
pawn Код:
CMD:hi(playerid, params[])
{
new str[128];
if(sscanf(params, "s[128]", str)) return SendClientMessage(playerid, -1, "usage message here.");
// your code etc.
}
And that's just the bottom of sscanf, the thread for sscanf holds a lot more info.
Now, the reason to use zcmd and sscanf is to improve speed and readability of your code, it will greatly help you in the future.
Happy coding!