06.10.2014, 16:59
Let's say that's your command to open the menu to buy guns, be sure to #define the name of the dialog like #define GUN_MENU.
And on dialog response put this.
I tryed it to explain it to you somehow, but check this if you wish https://sampwiki.blast.hk/wiki/OnDialogResponse
pawn Код:
CMD:buygun(playerid, params[])
{
ShowPlayerDialog(playerid, GUN_MENU, DIALOG_STYLE_LIST, "Ammu Nation", "Deagle\nM4 Assault Rifle", "Buy", "Cancel");
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == BUY_GUN)
{
if(response) // If they clicked 'Select' or double-clicked a weapon
{
if(listitem == 0)
{
if(GetPlayerCash(playerid) >= 1000)
{
GivePlayerValidWeapon(playerid, 24, 100); // Weapon ID, Ammo
GivePlayerCash(playerid, -1000);
SendClientMessageEx(playerid, COLOR_WHITE, "You have purchased a Desert Eagle!");
return 1;
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't afford that weapon!");
return 1;
}
}
if(listitem == 1)
{
if(GetPlayerCash(playerid) >= 1000)
{
GivePlayerValidWeapon(playerid, 31, 100); // Weapon ID, Ammo
GivePlayerCash(playerid, -1000);
SendClientMessageEx(playerid, COLOR_WHITE, "You have purchased an M4 Assasult Rifle!");
return 1;
}
else
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't afford that weapon!");
return 1;
}
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0; // You MUST return 0 here! Just like OnPlayerCommandText.
}