SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 31/12/2015, 11:16 AM   #1
VincenzoDrift
Little Clucker
 
VincenzoDrift's Avatar
 
Join Date: Jun 2014
Posts: 47
Reputation: 3
Default dialog menu - listitem's name

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
         }
}
__________________
Sorry for my bad english
VincenzoDrift is offline   Reply With Quote
Old 31/12/2015, 11:54 AM   #2
Larceny
Huge Clucker
 
Larceny's Avatar
 
Join Date: Apr 2006
Posts: 276
Reputation: 228
Default Re: dialog menu - listitem's name

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://wiki.sa-mp.com/wiki/OnDialogResponse
Larceny is offline   Reply With Quote
Old 31/12/2015, 12:12 PM   #3
Stanford
Gangsta
 
Stanford's Avatar
 
Join Date: Feb 2012
Posts: 983
Reputation: 84
Default Re: dialog menu - listitem's name

Use the inputtext parameter to compare between the strings.
__________________
******: "That code compiles perfectly, but I can tell you now it won't make me a cup of tea."

******: "I've said this before. People think that MySQL is some simple plug-and-play magic bullet that you can use to just make your mode instantly better. They don't realise that the "L" in "SQL" means "language". So instead of programming PAWN, and using a bit of this mystery thing, you are now programming in two languages at once. If you spend months learning PAWN, you should spend the same time learning SQL, if not more - it is probably the more complex of the two languages, and not something that just gets bolted on to the side."
Stanford is offline   Reply With Quote
Old 31/12/2015, 12:24 PM   #4
VincenzoDrift
Little Clucker
 
VincenzoDrift's Avatar
 
Join Date: Jun 2014
Posts: 47
Reputation: 3
Default Re: dialog menu - listitem's name

Thanks +rep
__________________
Sorry for my bad english
VincenzoDrift is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dialog Listitem ancezas Scripting Help 8 04/03/2014 02:14 PM
Dialog listitem question. fordawinzz Scripting Help 4 14/09/2012 09:23 PM
Dialog listitem problem? Dr Help Archive 3 25/07/2011 09:29 PM
[Help]Dialog's listitem Smage Help Archive 0 31/12/2009 08:01 AM


All times are GMT. The time now is 05:52 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.