dialog menu - listitem's name - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: dialog menu - listitem's name (
/showthread.php?tid=597436)
dialog menu - listitem's name -
VincenzoDrift - 31.12.2015
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
}
}
Re: dialog menu - listitem's name -
Larceny - 31.12.2015
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
Re: dialog menu - listitem's name -
Stanford - 31.12.2015
Use the inputtext parameter to compare between the strings.
Re: dialog menu - listitem's name -
VincenzoDrift - 31.12.2015
Thanks
+rep