08.06.2014, 19:16
Quote:
Using ++ after the variable returns the old value. So it will start by checking if "cmdplayers[0]" is not -1 and in the code inside the loop "i" will be 1. You could declare "i" with default value of -1 and use "++i" instead.
But if any value is not -1, the loop will stop so it won't work even you had changed the above. Use a for loop instead and check if the value is not -1 in an if statement. |
So the right code should look like:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case MY_COMMAND: //the id of your command dialog
{
if(response) //if you pressed the first button, like "OK"
{
if(strlen(inputtext)) //if you entered at least 1 character
{
new cmdplayers[MAX_PLAYERS], i=-1;
sscanf(inputtext, "A<i>(-1)[MAX_PLAYERS]", cmdplayers);
//You put the ids you introduced in the array, and set the rest to -1 cuz 0 might be a playerid.
while(cmdplayers[++i]!=-1 && i<MAX_PLAYERS) //change for each playerid you introduced
{
//do what you have to do with the playerid
}
}
}
}
}
return 1;
}