26.02.2014, 00:53
pawn Код:
#include <a_samp>
#define DIALOG_WEAPONS 3
// In some command
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "Desert Eagle\nAK-47\nCombat Shotgun\n Sniper Rifle", "Select", "Close");
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/weapons", true))
{
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Choose your weapon", "Desert Eagle ($10000)\nAK-47 ($20000)\nCombat Shotgun($20000)\nSniper Rifle ($50000)", "Purchase", "Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEAPONS)
{
if(response) // If they clicked 'Select' or double-clicked a weapon
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
GivePlayerMoney(playerid, -10000);
GivePlayerWeapon(playerid, WEAPON_DESERT EAGLE, 14); // Give them a desert eagle
}
case 1:
{
if(GetPlayerMoney(playerid) < 20000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
GivePlayerMoney(playerid, -20000);
GivePlayerWeapon(playerid, WEAPON_AK-47, 120); // Give them an AK-47
}
case 2:
{
if(GetPlayerMoney(playerid) < 20000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
GivePlayerMoney(playerid, -20000);
GivePlayerWeapon(playerid, WEAPON_COMBAT SHOTGUN, 28); // Give them a Combat Shotgun
}
case 3:
{
if(GetPlayerMoney(playerid) < 50000) return SendClientMessage(playerid, 0xFFFFFF, "You don't have enough cash.");
GivePlayerMoney(playerid, -50000);
GivePlayerWeapon(playerid, WEAPON_SNIPER RIFLE, 34); // Give them a Sniper Rifle
}
}
}
return 1; // We handled a dialog, so return 1. Just like OnPlayerCommandText.
}
return 0;
}