Taking the inputtext from a dialog and checking if it's a playerid
#1

I want to use the inputtext from a dialog and see if it's a valid playerid but it doesnt seem to work

Код:
else if(dialogid == DIALOG_TELLID)
    {
        if(response)
        {
            if(chatting[playerid] == 1) return SendClientMessage(playerid, -1, "{FF0000}You are already chatting with someone.");
			if(!IsNumeric(inputtext) || strlen(inputtext) > 5) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
			new id = strval(inputtext);
			
			return 1;
		}
    }
Reply
#2

And then check if the player is connected.
Код:
if(!IsNumeric(inputtext) || strlen(inputtext) > 5) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
new id = strval(inputtext);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
Reply
#3

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
And then check if the player is connected.
Код:
if(!IsNumeric(inputtext) || strlen(inputtext) > 5) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
new id = strval(inputtext);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
That's what I had before but when I use it won't work at all. The dialog just closes

EDIT: NVM it works!
Reply
#4

pawn Код:
else if(dialogid == DIALOG_TELLID)
    {
        if(response)
        {
            if(chatting[playerid] == 1) return SendClientMessage(playerid, -1, "{FF0000}You are already chatting with someone.");
            if(!IsNumeric(inputtext)) return SendClientMessage(playerid, -1, "{FF0000}You entered an invalid playerid.");
            new id = strval(inputtext);
            if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{FF0000}Invalid player id.");
           
            return 1;
        }
    }
EDIT: Was too late.
Reply
#5

If you press one of the buttons, it will close the dialog, i don't think you can stop that.
But it doesn't send any messages either when it's an invalid ID?
Reply
#6

I would advice to simply run sscanf against it. Way simpler, and it provides the ability to input a name as well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)