Dialog question
#1

How I can when I enter a name in dialog somthing will happen to that player, example slapping him
Reply
#2

Get the inputtext and use the following function
PHP код:
stock GetPlayerIdFromName(playername[])
{
    for(new 
0<= MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
             new 
playername2[MAX_PLAYER_NAME];
              
GetPlayerName(iplayername2sizeof(playername2));
              if(
strcmp(playername2playernametruestrlen(playername2)) == 0)
              {
                return 
i;
              }
        }
      }
    return 
INVALID_PLAYER_ID;

Reply
#3

okey, now give me an example of dialog.
Thanks for helping
Reply
#4

pawn Код:
CMD:slap(playerid,params[])
{
    ShowPlayerDialog(playerid, //blahblahblah
}

public OnDialogResponse(//more blah)
{
    if(dialogid == DIALOG_BLAH)
    {
        new id = GetPlayerIdFromName(inputtext);
        Slap(id);
Reply
#5

I don't understand this mate...
I am making mdc system, I want when I enter player's name it will show the information of the player, but I couldn't make this INPUT dialog...
Reply
#6

pawn Код:
enum
{
    DIALOG_PLAYERNAME
}

//Here is the input dialog:
ShowPlayerDialog(playerid, DIALOG_PLAYERNAME, DIALOG_STYLE_INPUT, "Mobile Data Computer", "Enter the name of the person you want to get information about.", "Search", "Close");
This is the line that shows the dialog to the player (to the cop)

Well, to continue, you need an algorithm that searches through player data, so tell us how you store your data (database, files, which db/file system)
Reply
#7

you mean PlayerInfo[playerid][pAge] and shiz?
Reply
#8

Pretty easy if you use the sscanf plugin, one can type either userid OR username and it's a pretty small code...
once again, indentation is fucked by forums...
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
	    case DIALOG_INPUT:
	    {
	        if(response)
	        {
	            new userid;
				if(sscanf(inputtext,"u",userid)) return ShowPlayerDialog(playerid,DIALOG_INPUT,DIALOG_STYLE_INPUT,"Enter name/userid","Error: Enter the name/userid","OK","Cancel");
				DoSomethingToPlayer(userid); // Do whatever
	        }
	    }
	}
	return 1;
}
Reply
#9

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem,
{
  if(dialogid == blablabla)
  {
    if(response)
      {
    switch(dialogid)
    {
        case DIALOG_INPUT:
        {
            if(response)
            {
                new userid;
                if(sscanf(inputtext,"u",userid)) return ShowPlayerDialog(playerid,DIALOG_INPUT,DIALOG_STYLE_INPUT,"Enter name/userid","Error: Enter the name/userid","OK","Cancel");
               Showplayerdialog(userid, Blabla);
            }
        }
    }
    return 1;
}
This code would work?
I am typing via phone.
Reply
#10

Why are you using an IF Statement on dialog response to check if the dialog is == to a certain ID...
Use a switch statement.
Код:
switch(dialogid)
Pointless saying

if(dialog == blah blah

because if it doesn't == that specific dialog name, It wont do nothing what so ever.. so If you have more than 1 dialog under that..
If it doesn't == the first dialog your if statement is asking it will simpy skip an close....

This is a HELP section..
Not a "DO IT FOR ME" Section..
If you want it done for you..
Post in the right place?



All I can see in this thread is the following...

How do I do *BlahBlah*

someone tells you...
You then ask for an "example"..
He gives you one..
"I don't understand"

In other words...

Hey can someone make this "blah blah" into a dialog for me.. so I can copy paste
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)