dialog menu - listitem's name
#1

Hi i need to compare a string with a item name. How i do this?

Code:
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, "Menщ", "first item/nseconditem/nthird item", "Play", "Exit");
return 1;
OnPlayerDialog
Code:
case D_CHARACTERS_MENU:
{
         if(!strcmp(listitem, "first item")) //It don't work because listitem is the item number
    	 {
                         //do this
         }
         else if(!strcmp(listitem, "second item"))
         {
                         //do this
         }
}
Reply
#2

Why not use the ID instead?
Code:
#define DIALOG_WEAPONS 3
 
// In some command
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun", "Select", "Close");
 
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
            switch(listitem)
            {
                case 0: GivePlayerWeapon(playerid, WEAPON_DEAGLE, 14); // Give them a desert eagle
                case 1: GivePlayerWeapon(playerid, WEAPON_AK47, 120); // Give them an AK-47
                case 2: GivePlayerWeapon(playerid, WEAPON_SHOTGSPA, 28); // Give them a Combat Shotgun
            }
        }
        return 1;
    } 
    return 0;
}
https://sampwiki.blast.hk/wiki/OnDialogResponse
Reply
#3

Use the inputtext parameter to compare between the strings.
Reply
#4

Thanks +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)