19.05.2010, 19:44
HEllo, i am looking at the example on samp wiki and i got a few questions..
Okay... First of all, what exactly does strtok do? i thought it takes a string and searchs it to find the first space, Then it stores whatever is after it, into a string...but that would mean if you used
then
would mean that tmp is equal to 20??
If this is true then why does it use
at the start...This means when you compare cmd to the command name, it wont match because cmd would be equal to 20? so it is comparing 20 to /sayhello
-Thanks for helping in advance
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[30]; new idx; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/sayhello", true) == 0) { new tmp[30]; // assign the id (written by the user) to tmp tmp = strtok(cmdtext, idx); // convert the id to an integer using strval (this is essential) // and assign to otherplayer new otherplayer = strval(tmp); if(IsPlayerConnected(otherplayer)) { SendClientMessage(otherplayer, 0xFFFF00AA, "Hi, hello!"); } return 1; } return 0; }
Код:
* Martin_Smith 20...
Код:
tmp = strtok(cmdtext, idx);
If this is true then why does it use
Код:
new cmd[30]; new idx; cmd = strtok(cmdtext, idx);
-Thanks for helping in advance