Posts: 19
Threads: 0
Joined: Jul 2008
Reputation:
0
Here
if(strcmp(cmdtext, "/InviteDrift", true) == 0)
{
tmp = strtok(cmdtext, idx);
you are comparing the whole thing typed by the player (maybe "/invitedrift 5"?), so that's different from "/Invitedrift", and will never find the command.
Later you store in tmp the playerid.
tmp = strtok(cmdtext, idx);
If you see that, you forgot to do the same in the if statement. It would be
tmp = strtok (cmdtext, idx); // added
if(strcmp(tmp, "/InviteDrift", true) == 0)
{
tmp = strtok(cmdtext, idx);
Posts: 155
Threads: 52
Joined: Apr 2009
Reputation:
0
so i put "tmp" instead "cmdtext"?
modify: don't work XD, and i didn't really understood, you said too much times "tmp = strtok "
Posts: 19
Threads: 0
Joined: Jul 2008
Reputation:
0
You use strtok to split a player command, and analize separately each word in the command
"/Invitedrift 5"
are two words: "/invitedrift" and "5", both on cmdtext. You can't analize cmdtext within an 'if (strcmp(blabla) == 0)' because you get all the words and it fails on what you want, so your first need is to get the command word. That's why you use strtok for first time
tmp = strtok (cmdtext, idx) // first use of strtok -> you get "/invitedrift"
now you can compare in the if statement.
if (strcmp (tmp, "/Invitedirft", true) == 0)
If the result of the comparison is true, you need to get the playerid to be invited, so again you use strtok
tmp = strtok (cmdtext, idx) // second use of strtok -> you get "5" (or whatever playerid might be)
If it doesn't work, did you set idx = 0?