Target ID to inputtext
#1

Hello guys, I do not know, how can I make dialog with inputtext, where will be targetid as inputtext. For example I am in kick dialog, where admin type to dialog 23 and it will kick the ID 23 player. Also want to make when admin type to dialog for example two targetids, each targetid will be after space, for example admin type to dialog 22 25 23, and it will kick these players. Thanks.
Reply
#2

I dont understend you, maybe this will help you Click me !
Reply
#3

I recommend sscanf with the parameter "u". You can also use the delimiter coma(,) with sscanf.
Reply
#4

I know about sscanf but how can I make so the ID of the player, who is putted to the dialog by admin will be kicked..
Reply
#5

Show a dialog with style DIALOG_STYLE_INPUT so admins can input a player's ID.

In OnDialogResponse, if the dialogid is the one you gave for that dialog and response is 1:
pawn Код:
Kick(strval(inputtext));
Reply
#6

Quote:
Originally Posted by Riwerry
Посмотреть сообщение
I know about sscanf but how can I make so the ID of the player, who is putted to the dialog by admin will be kicked..
Convert inputtext(string) into integer/number using strval

Example Code
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid = 1) //example dialog id
    {
        new otherid = strval(inputtext);
        Kick(otherid);
    }
    return true;
}
Код:
This forum requires that you wait 240 seconds between posts. Please try again in 79 seconds.
- kgui

EDIT - Konstantinos was faster because of this timer -_-
Reply
#7

yeah and as i said how i can make multiple target ids? for example 20 5 6 and it will kick those all..
Reply
#8

What you're trying to do is a very weird way of doing it to be honest, IMO. I would make multiple input dialogs rather, and then let the user put in the id's one after another in the dialogs.

https://sampwiki.blast.hk/wiki/Strdel

- Loop through the whole string by using strlen (as in for(new i = 0; i <= strlen(inputtext)...).
- Search for a "space", by that I mean searching for (' ') without brackets:
if (name[i] == ' ') then use strdel, otherwise continue the loop.
- Then use as suggested above, strval.

I won't make the code for you because I find this too complicated for me to do in one minute. I'd have to test the code etc. :P
Reply
#9

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid = KICK)
    {
               new KickID;
               if(!response)
               {
                       SendClientMessage(//Whatever);
               }
               else if (sscanf(inputtext, "u", KickID)) //PlayerID/Player_Name can be accepted with "u"
	       {
                       SendClientMessage(playerid, 0xFF0000FF, "You can't leave it Blank.");
                       //Show Dialog again;
               }
               else
               {
                       Kick(KickID);
               }
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)