dialog listbox and input
#1

so I have
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[124];
    switch(dialogid)
    {
    	case 1:
     	{
      		if(!response) return Kick(playerid);

			if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
   			{
      			SendClientMessage(playerid, COL_GREY, "Please enter a password that is greater than 6 characters or less than 32 characters.");
         		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Welcome to "ServerName"", "Enter your desired password below to sucessfully register.", "Continue", "Cancel");
           		return 1;
           	}
            else
            {
           		RegisterPlayer(playerid, inputtext);
              	PlayerVar[playerid][Authenticated] = 1;
               	format(PlayerVar[playerid][Name], MAX_PLAYER_NAME, GetPlayersNameWithUnderScore(playerid));
                format(PlayerVar[playerid][Password], 32, "%s", inputtext);
                format(PlayerVar[playerid][Accent], 32, "American");
                GetPlayerIp(playerid, PlayerVar[playerid][IP], 32);
            }
		}
		case 2:
        {
			if(!response) return Kick(playerid);

			format(string, sizeof(string), "PlayerAccounts/%s.ini", GetPlayersNameWithUnderScore(playerid));
			if(fexist(string))
         	{
            	if(!strcmp(PlayerVar[playerid][Password], inputtext , false))
               	{
					INI_ParseFile(string, "LoadPlayer_%s", .bExtra = true, .extra = playerid);
					PlayerVar[playerid][Authenticated] = 1;
                    LoginPlayer(playerid);
                }
                else
                {
					SendClientMessage(playerid, COL_GREY, "The password you entered does not match, please reconnect for another try.");
                    Kick(playerid);
                }
			}
		}
	}
	return 1;
}
But I also want
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_WEAPONS)
    {
        if(response) // If they clicked 'Select' or double-clicked a weapon
        {
            // Give them the weapon
            if(listitem == 0) // They selected the first item - Desert Eagle
            {
                GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle
            }
            if(listitem == 1) // They selected the second item - AK-47
            {
                GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47
            }
            if(listitem == 2) // They selected the third item - Desert Eagle
            {
                GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun
            }
        }
        return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
    }
 
    return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}
In there, how do i do this?
Reply
#2

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[124];
    switch(dialogid)
    {
        case 1:
        {
            if(!response) return Kick(playerid);

            if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
            {
                SendClientMessage(playerid, COL_GREY, "Please enter a password that is greater than 6 characters or less than 32 characters.");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Welcome to "ServerName"", "Enter your desired password below to sucessfully register.", "Continue", "Cancel");
                return 1;
            }
            else
            {
                RegisterPlayer(playerid, inputtext);
                PlayerVar[playerid][Authenticated] = 1;
                format(PlayerVar[playerid][Name], MAX_PLAYER_NAME, GetPlayersNameWithUnderScore(playerid));
                format(PlayerVar[playerid][Password], 32, "%s", inputtext);
                format(PlayerVar[playerid][Accent], 32, "American");
                GetPlayerIp(playerid, PlayerVar[playerid][IP], 32);
            }
        }
        case 2:
        {
            if(!response) return Kick(playerid);

            format(string, sizeof(string), "PlayerAccounts/%s.ini", GetPlayersNameWithUnderScore(playerid));
            if(fexist(string))
            {
                if(!strcmp(PlayerVar[playerid][Password], inputtext , false))
                {
                    INI_ParseFile(string, "LoadPlayer_%s", .bExtra = true, .extra = playerid);
                    PlayerVar[playerid][Authenticated] = 1;
                    LoginPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COL_GREY, "The password you entered does not match, please reconnect for another try.");
                    Kick(playerid);
                }
            }
        }
        case DIALOG_WEAPONS:
        {
            if(response) // If they clicked 'Select' or double-clicked a weapon
            {
                // Give them the weapon
                if(listitem == 0) // They selected the first item - Desert Eagle
                {
                    GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle
                }
                if(listitem == 1) // They selected the second item - AK-47
                {
                    GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47
                }
                if(listitem == 2) // They selected the third item - Desert Eagle
                {
                    GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun
                }
            }
        }
    }
    return 1;
}
Reply
#3

I copied your code and edited it but it gives me
Quote:

C:\Users\x3990.003\Desktop\samp server\gamemodes\PZ.pwn(1671) : error 008: must be a constant expression; assumed zero

in the red line
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new string[124];
    switch(dialogid)
    {
        case 1:
        {
            if(!response) return Kick(playerid);

            if(strlen(inputtext) < 6 || strlen(inputtext) > 32)
            {
                SendClientMessage(playerid, COL_GREY, "Please enter a password that is greater than 6 characters or less than 32 characters.");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Welcome to "ServerName"", "Enter your desired password below to sucessfully register.", "Continue", "Cancel");
                return 1;
            }
            else
            {
                RegisterPlayer(playerid, inputtext);
                PlayerVar[playerid][Authenticated] = 1;
                format(PlayerVar[playerid][Name], MAX_PLAYER_NAME, GetPlayersNameWithUnderScore(playerid));
                format(PlayerVar[playerid][Password], 32, "%s", inputtext);
                format(PlayerVar[playerid][Accent], 32, "American");
                GetPlayerIp(playerid, PlayerVar[playerid][IP], 32);
            }
        }
        case 2:
        {
            if(!response) return Kick(playerid);

            format(string, sizeof(string), "PlayerAccounts/%s.ini", GetPlayersNameWithUnderScore(playerid));
            if(fexist(string))
            {
                if(!strcmp(PlayerVar[playerid][Password], inputtext , false))
                {
                    INI_ParseFile(string, "LoadPlayer_%s", .bExtra = true, .extra = playerid);
                    PlayerVar[playerid][Authenticated] = 1;
                    LoginPlayer(playerid);
                }
                else
                {
                    SendClientMessage(playerid, COL_GREY, "The password you entered does not match, please reconnect for another try.");
                    Kick(playerid);
                }
            }
        }
        case DIALOG_SEARCH:
        {
            if(response)
            {
                if(listitem == 0) // WP crate
                {
                    SendClientMessage(playerid, COL_GREY, "The weapon crate has been marked on your map.");
                }
                if(listitem == 1) // Grocery store
                {
                    SendClientMessage(playerid, COL_GREY, "The grocery store has been marked on your map.");
                }
                if(listitem == 2) // Hospital
                {
                    SendClientMessage(playerid, COL_GREY, "The hospital has been marked on your map.");
                }
                if(listitem == 3) // Fire department
                {
                    SendClientMessage(playerid, COL_GREY, "The fire department has been marked on your map.");
                }
            }
        }
    }
    return 1;
}
Reply
#4

Where is line 1671
Reply
#5

Quote:
Originally Posted by Frede
Посмотреть сообщение
Where is line 1671
Look in the code, i marked it red
Reply
#6

sorry(im colorblind) what did you define DIALOG_SEARCH as...

EDIT: It compile fine in my compiler. It most be something external
Reply
#7

Код:
new DIALOG_SEARCH;
ShowPlayerDialog(playerid, DIALOG_SEARCH, DIALOG_STYLE_LIST, "Search a location", "Weapon crate\nGrocery store\nHospital\nFire department", "Okay", "Cancel");
Reply
#8

Dude you need to #define them or put them in a enum

like this:
pawn Код:
#define DIALOG_WEAPONS 1
#define DIALOG_SEARCH 2
...
or

pawn Код:
enum
{
    DIALOG_WEAPONS
    DIALOG_SEARCH
    ...
}
if you want to use a new, then you need to do
pawn Код:
new DIALOG_SEARCH = 1;
new DIALOG_WEAPONS = 2;
...
and im not sure that will work
Reply
#9

Quote:
Originally Posted by Frede
Посмотреть сообщение
Dude you need to #define them or put them in a enum

like this:
pawn Код:
#define DIALOG_WEAPONS 3
#define DIALOG_SEARCH 4
thanks!
Reply
#10

No problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)