Особенности
• Возможность динамически изменять цены каждого оружия, перечисленных в диалоговом окне
• Оружие покупки (магазин)
Команды
Regular user: /weapons
RCON Admin user: /editweapons
Код: Выделить всё
#include <a_samp>
#include <ZCMD>
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_GREEN 0x33AA33AA
#define COLOR_ORANGE 0xFFCC33AA
#define DIALOG_WEAPON 7878
#define DIALOG_EDITWEAPON 8787
#define DIALOG_LISTITEM1 8000
#define DIALOG_LISTITEM2 8001
#define DIALOG_LISTITEM3 8002
#define DIALOG_LISTITEM4 8003
new
ak47 = 500,
deagle = 300,
mp5 = 300,
colt45 = 200
;
stock IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
public OnFilterScriptInit()
{
print("Dynamic dialog: Weapon by Blunt");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
main(){}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new list1[300],string[100],type = strval(inputtext);
format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
switch(dialogid)
{
case DIALOG_WEAPON:
{
if(!response) return 1;
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) != ak47) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
GivePlayerWeapon(playerid,30,500);
GivePlayerMoney(playerid,-ak47);
}
case 1:
{
if(GetPlayerMoney(playerid) != deagle) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
GivePlayerWeapon(playerid,24,500);
GivePlayerMoney(playerid,-deagle);
}
case 2:
{
if(GetPlayerMoney(playerid) != mp5) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
GivePlayerWeapon(playerid,29,500);
GivePlayerMoney(playerid,-mp5);
}
case 3:
{
if(GetPlayerMoney(playerid) != colt45) return SendClientMessage(playerid,COLOR_GREY,"Insufficient funds for this item");
GivePlayerWeapon(playerid,22,500);
GivePlayerMoney(playerid,-colt45);
}
}
}
case DIALOG_EDITWEAPON:
{
if(!response) return 1;
switch(listitem)
{
case 0:{ShowPlayerDialog(playerid,DIALOG_LISTITEM1,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}AK-47","Submit","Back");}
case 1:{ShowPlayerDialog(playerid,DIALOG_LISTITEM2,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}Desert Eagle","Submit","Back");}
case 2:{ShowPlayerDialog(playerid,DIALOG_LISTITEM3,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}MP5","Submit","Back");}
case 3:{ShowPlayerDialog(playerid,DIALOG_LISTITEM4,DIALOG_STYLE_INPUT,"WEAPON PRICE EDITOR","Type in a price that you want to set for the {33AA33}Colt45","Submit","Back");}
}
}
case DIALOG_LISTITEM1:
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
ak47 = type;
format(string,sizeof(string),"You have updated the price of the AK-47 to $%d",type);
SendClientMessage(playerid,COLOR_GREEN,string);
}
case DIALOG_LISTITEM2:
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
deagle = type;
format(string,sizeof(string),"You have updated the price of the Desert Eagle to $%d",type);
SendClientMessage(playerid,COLOR_GREEN,string);
}
case DIALOG_LISTITEM3:
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
mp5 = type;
format(string,sizeof(string),"You have updated the price of the MP5 to $%d",type);
SendClientMessage(playerid,COLOR_GREEN,string);
}
case DIALOG_LISTITEM4:
{
if(!response) return ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
colt45 = type;
format(string,sizeof(string),"You have updated the price of the Colt45 to $%d",type);
SendClientMessage(playerid,COLOR_GREEN,string);
}
}
return 1;
}
COMMAND:weapons(playerid)
{
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return SendClientMessage(playerid, COLOR_GREY, "You must be on foot to use this command.");
new list1[300];
format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
ShowPlayerDialog(playerid,DIALOG_WEAPON,DIALOG_STYLE_LIST,"WEAPONS",list1,"Select","Cancel");
return 1;
}
COMMAND:editweapons(playerid)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "Command for admin-use only.");
SendClientMessage(playerid,COLOR_GREEN,"To edit a price, double click/select an item on the list.");
new list1[300];
format(list1,300,"{FFFFFF}AK-47 {FFCC33}($%d) \n{FFFFFF}Desert Eagle {FFCC33}($%d) \n{FFFFFF}MP5 {FFCC33}($%d) \n{FFFFFF}Colt45 {FFCC33}($%d)",ak47,deagle,mp5,colt45);
ShowPlayerDialog(playerid,DIALOG_EDITWEAPON,DIALOG_STYLE_LIST,"EDIT PRICES",list1,"Select","Cancel");
return 1;
}