Using Dialogs to Get Player ID
#1

Hello. When I am using a DIALOG_STYLE_INPUT, I want to be able to use the inputtext to get a players name/ID. So, basically, when someone types /setdiv, it will say in a dialog, "Enter the Player's ID/Name" and when they enter it, the response checks to see if the ID they entered is connected/isn't a invalid ID. My problem with this is, it won't let me use inputtext to find the player's ID/name and store it in a variable. The codes give me array errors.

Here is my code:
pawn Код:
new giveplayerid[MAX_PLAYER_NAME];
            strmid(giveplayerid, inputtext, 0, strlen(inputtext), 24);
            giveplayerid = inputtext;
            if(giveplayerid == INVALID_PLAYER_ID)
            {
                ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "Invalid entry. Try again\nEnter the name of the player or the ID:","Move On", "Cancel");
                return 1;
            }
            if(!IsPlayerConnected(giveplayerid))
            {
                ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "Cop is not connected. Try again\nEnter the name of the player or the ID:","Move On", "Cancel");
                return 1;
            }
            if(PlayerInfo[giveplayerid][pMember] != 1)
            {
                ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "That player is not in your faction. Try again.\nEnter the name of the player or the ID:","Move On", "Cancel");
                return 1;
            }
            giveplayerid = SelectDivisionID;
Reply
#2

Use strval and not strmid xxxD Also doesnt have to be string.

pawn Код:
new giveplayerid = strval(inputtext);
if(giveplayerid == INVALID_PLAYER_ID)
{
    ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "Invalid entry. Try again\nEnter the name of the player or the ID:","Move On", "Cancel");
    return 1;
}
if(!IsPlayerConnected(giveplayerid))
{
    ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "Cop is not connected. Try again\nEnter the name of the player or the ID:","Move On", "Cancel");
    return 1;
}
if(PlayerInfo[giveplayerid][pMember] != 1)
{
    ShowPlayerDialog(playerid,7, DIALOG_STYLE_INPUT, "Set Division", "That player is not in your faction. Try again.\nEnter the name of the player or the ID:","Move On", "Cancel");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)