still get processed
#1

Код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
	if(dialogid==DIALOG_VOTEKICK && response)
	{
		if(IsVoteKickStarted == true) return SendClientMessage(playerid, COLOR_ERROR,"[ERROR:] {BBBBBB}A votekick has been already started. Wait until it finish to ask for a new one");
		if(IsNumeric(inputtext)) StartVoteKick(strval(inputtext));
		else
		{
			for(new i = 0; i<MAX_PLAYERS; i++)
				{
				GetPlayerName(playerid, name, sizeof(name));
				if(!strcmp(inputtext, name, true))
					{
					StartVoteKick(i);
					break;
					}
				}
		}
		if(PlayerToKick == -1) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR:] {BBBBBB}Player not found.");

		if(strval(inputtext) == playerid) return SendClientMessage(playerid, COLOR_ERROR, "[ERROR:] {BBBBBB}You Cant Votekick yourself.");
		GetPlayerName(playerid, name2, sizeof(name2));
		format(string, sizeof(string), "{C14124}%s{BBBBBB} has started a votekick for {C14124}%s{BBBBBB}. Type {60B149}Yes{BBBBBB} or {B35349}No{BBBBBB} to vote.", name2, name);
		SendClientMessageToAll(COLOR_OK, string);
		return 1;
	}
	return 1;
}
if i use that,if the player input id of himself,votekick still processed.
Reply
#2

Well yes, what did you expect? Code is evaluated top to bottom, not in some random order. If the input is numeric it starts the votekick, regardless of what number it is. If you input 3487 it will even attempt to start with that number. Re-order the code and make sure you only invoke StartVoteKick after you have ensured that the input is valid. You might also want to use sscanf to make it easier.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)