PHP Code:
/* Sublime AMXX Editor v2.2 */
#include <amxmodx>
// #include <amxmisc>
#include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
#include <fun>
// #include <xs>
// #include <sqlx>
new PRIMARY_WEAPONS_BITSUM = (1 << CSW_SCOUT) | (1 << CSW_XM1014) | (1 << CSW_MAC10) | (1 << CSW_AUG) | (1 << CSW_UMP45) | (1 << CSW_SG550) | (1 << CSW_GALIL) | (1 << CSW_FAMAS) | (1 << CSW_AWP) | (1 << CSW_MP5NAVY) | (1 << CSW_M249) | (1 << CSW_M3) | (1 << CSW_M4A1) | (1 << CSW_TMP) | (1 << CSW_G3SG1) | (1 << CSW_SG552) | (1 << CSW_AK47) | (1 << CSW_P90)
new SECONDARY_WEAPONS_BITSUM = (1 << CSW_GLOCK18) | (1 << CSW_USP) | (1 << CSW_P228) | (1 << CSW_DEAGLE) | (1 << CSW_FIVESEVEN) | (1 << CSW_ELITE)
const ZOMBIE_TEAM = 1
const HUMAN_TEAM = 2
const RIFLES_CATEGORY = 3
const PISTOLS_CATEGORY = 2
const BOMBS_CATEGORY = 1
const ALL_GRENADES = 0
enum _:Guns_Framework
{
Weapon_Fullname[64],
Weapon_ID[24],
Weapon_Type,
Weapon_Ammo,
Weapon_Cost,
Weapon_Category
}
enum _:Health_Framework
{
Health,
Cost,
Team
}
new const HealthItems[][Health_Framework] =
{
{ 300, 1000, ZOMBIE_TEAM },
{ 500, 1500, ZOMBIE_TEAM },
{ 1000, 2000, ZOMBIE_TEAM },
{ 2000, 5000, ZOMBIE_TEAM },
{ 30, 1000, HUMAN_TEAM },
{ 50, 1500, HUMAN_TEAM },
{ 100, 2500, HUMAN_TEAM },
{ 200, 5000, HUMAN_TEAM }
}
new const GunsItem[][Guns_Framework] =
{
{ "AK47", "weapon_ak47", CSW_AK47, 200, 2300, RIFLES_CATEGORY },
{ "M4A1 Carbine", "weapon_m4a1", CSW_M4A1, 200, 2000, RIFLES_CATEGORY },
{ "FAMAS", "weapon_famas", CSW_FAMAS, 200, 2000, RIFLES_CATEGORY },
{ "GALIL", "weapon_galil", CSW_GALIL, 200, 1500, RIFLES_CATEGORY },
{ "M249", "weapon_m249", CSW_M249, 200, 13000, RIFLES_CATEGORY },
{ "G3SG1", "weapon_g3sg1", CSW_G3SG1, 200, 13000, RIFLES_CATEGORY },
{ "Deagle", "weapon_deagle", CSW_DEAGLE, 200, 1000, PISTOLS_CATEGORY },
{ "USP", "weapon_usp", CSW_USP, 200, 400, PISTOLS_CATEGORY },
{ "Glock", "weapon_glock18", CSW_GLOCK18, 200, 200, PISTOLS_CATEGORY },
{ "FIVESEVEM", "weapon_fiveseven", CSW_FIVESEVEN, 200, 600, PISTOLS_CATEGORY },
{ "HE Gernade", "weapon_hegrenade", CSW_HEGRENADE, 1, 500, BOMBS_CATEGORY },
{ "SMOKE", "weapon_smokegrenade", CSW_SMOKEGRENADE, 1, 400, BOMBS_CATEGORY },
{ "Flash", "weapon_flashbang", CSW_FLASHBANG, 1, 300, BOMBS_CATEGORY },
{ "Bombs Pack", "", 0, 0, 500, ALL_GRENADES }
}
new const SayShop[][] =
{
"say /shop",
"say_team /shop",
"say shop",
"say_team shop"
}
new const PluginAuthority[][] =
{
"Ancient shop",
"0.0.1",
"SayWhat?!"
}
new saytext, maxplayer
public plugin_init()
{
register_plugin(PluginAuthority[0], PluginAuthority[1], PluginAuthority[2])
for(new i = 0; i < sizeof(SayShop); i++)
register_clcmd(SayShop[i], "GeneralShop")
maxplayer = get_maxplayers()
saytext = get_user_msgid("SayText")
}
public GeneralShop(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED
switch(get_user_team(id))
{
case HUMAN_TEAM: CTMainShop(id)
case ZOMBIE_TEAM: HealthMenu(id)
}
return PLUGIN_HANDLED
}
public CTMainShop(id)
{
new menu = menu_create("\rBB Shop\y |\w Human Items:", "main_handler")
menu_additem(menu, "\wGuns", "0", 0)
menu_additem(menu, "\wHealth", "1", 0)
menu_display(id, menu, 0)
}
public main_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[6], callback, item_index
menu_item_getinfo(menu, item, access, num, charsmax(num), _,_, callback)
item_index = str_to_num(num)
switch(item_index)
{
case 0: GunsMenu(id)
case 1: HealthMenu(id)
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public GunsMenu(id)
{
if(!is_user_alive(id))
return PLUGIN_HANDLED
new menu = menu_create("\rBB Shop\y |\w Weapons:", "guns_main_handler")
menu_additem(menu, "\wRifles", "0", 0)
menu_additem(menu, "\wPistols", "1", 0)
menu_additem(menu, "\wBombs", "2", 0)
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public guns_main_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[6], callback, item_index
menu_item_getinfo(menu, item, access, num, charsmax(num), _,_, callback)
item_index = str_to_num(num)
switch(item_index)
{
case 0: RiflesMenu(id)
case 1: PistolsMenu(id)
case 2: BombsMenu(id)
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
public RiflesMenu(id)
{
new item[64], num[3], menu
menu = menu_create("\rBB SHOP\y |\w Rifles:", "rifles_handler")
for(new i = 0; i < sizeof(GunsItem); i++)
{
if(GunsItem[i][Weapon_Category] != RIFLES_CATEGORY)
continue
num_to_str(i, num, charsmax(num))
formatex(item, charsmax(item), "\w%s \r|\y Rs:\w %i$", GunsItem[i][Weapon_Fullname], GunsItem[i][Weapon_Cost])
menu_additem(menu, item, num, 0)
}
if(menu_items(menu) <= 0)
{
printf(id, "^x04[BB Shop]^x01 No items were loaded for your category.")
return PLUGIN_HANDLED
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public rifles_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[3], callback, item_index, money
menu_item_getinfo(menu, item, access, num, charsmax(num), _, _, callback)
item_index = str_to_num(num)
money = cs_get_user_money(id) - GunsItem[item_index][Weapon_Cost]
menu_destroy(menu)
if(money < 0)
{
printf(id, "^x04[BB Shop]^x01 You have insufficient money for this item.")
return PLUGIN_HANDLED
}
if(user_has_weapon(id, GunsItem[item_index][Weapon_Type]))
{
printf(id, "^x04[BB Shop]^x01 You already have this gun.")
return PLUGIN_HANDLED
}
cs_set_user_money(id, money)
drop_primary_weapons(id)
give_item(id, GunsItem[item_index][Weapon_ID])
cs_set_user_bpammo(id, GunsItem[item_index][Weapon_Type], GunsItem[item_index][Weapon_Ammo])
printf(id, "^x04[BB Shop]^x01 You bought^x03 %s^x01 for^x04 %i$^x01.", GunsItem[item_index][Weapon_Fullname], GunsItem[item_index][Weapon_Cost])
return PLUGIN_HANDLED
}
public PistolsMenu(id)
{
new item[64], num[3], menu
menu = menu_create("\rBB SHOP\y |\w Rifles:", "pistols_handler")
for(new i = 0; i < sizeof(GunsItem); i++)
{
if(GunsItem[i][Weapon_Category] != PISTOLS_CATEGORY)
continue
num_to_str(i, num, charsmax(num))
formatex(item, charsmax(item), "\w%s \r|\y Rs:\w %i$", GunsItem[i][Weapon_Fullname], GunsItem[i][Weapon_Cost])
menu_additem(menu, item, num, 0)
}
if(menu_items(menu) <= 0)
{
printf(id, "^x04[BB Shop]^x01 No items were loaded for your category.")
return PLUGIN_HANDLED
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public pistols_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[3], callback, item_index, money
menu_item_getinfo(menu, item, access, num, charsmax(num), _, _, callback)
item_index = str_to_num(num)
money = cs_get_user_money(id) - GunsItem[item_index][Weapon_Cost]
menu_destroy(menu)
if(money < 0)
{
printf(id, "^x04[BB Shop]^x01 You have insufficient money for this item.")
return PLUGIN_HANDLED
}
if(user_has_weapon(id, GunsItem[item_index][Weapon_Type]))
{
printf(id, "^x04[BB Shop]^x01 You already have this gun.")
return PLUGIN_HANDLED
}
cs_set_user_money(id, money)
drop_secondary_weapons(id)
give_item(id, GunsItem[item_index][Weapon_ID])
cs_set_user_bpammo(id, GunsItem[item_index][Weapon_Type], GunsItem[item_index][Weapon_Ammo])
printf(id, "^x04[BB Shop]^x01 You bought^x03 %s^x01 for^x04 %i$^x01.", GunsItem[item_index][Weapon_Fullname], GunsItem[item_index][Weapon_Cost])
return PLUGIN_HANDLED
}
public BombsMenu(id)
{
new item[64], num[3], menu
menu = menu_create("\rBB SHOP\y |\w Bombs:", "grenades_handler")
for(new i = 0; i < sizeof(GunsItem); i++)
{
if(GunsItem[i][Weapon_Category] != BOMBS_CATEGORY && GunsItem[i][Weapon_Category] != ALL_GRENADES)
continue
num_to_str(i, num, charsmax(num))
formatex(item, charsmax(item), "\w%s \r|\y Rs:\w %i$", GunsItem[i][Weapon_Fullname], GunsItem[i][Weapon_Cost])
menu_additem(menu, item, num, 0)
}
if(menu_items(menu) <= 0)
{
printf(id, "^x04[BB Shop]^x01 No items were loaded for your category.")
return PLUGIN_HANDLED
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public grenades_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[3], callback, item_index, money
menu_item_getinfo(menu, item, access, num, charsmax(num), _, _, callback)
item_index = str_to_num(num)
money = cs_get_user_money(id) - GunsItem[item_index][Weapon_Cost]
menu_destroy(menu)
if(money < 0)
{
printf(id, "^x04[BB Shop]^x01 You have insufficient money for this item.")
return PLUGIN_HANDLED
}
if(GunsItem[item_index][Weapon_Category] == ALL_GRENADES)
{
new num = 0
if(user_has_weapon(id, CSW_HEGRENADE))
num++
else
give_item(id, "weapon_hegrenade")
if(user_has_weapon(id, CSW_FLASHBANG))
num++
else
give_item(id, "weapon_flashbang")
if(user_has_weapon(id, CSW_SMOKEGRENADE))
num++
else
give_item(id, "weapon_smokegrenade")
if(num > 2)
{
printf(id, "^x04[BB Shop]^x01 You already have all kind of grenades.")
return PLUGIN_HANDLED
}
}
else
{
if(user_has_weapon(id, GunsItem[item_index][Weapon_Type]))
{
printf(id, "^x04[BB Shop]^x01 You already have this gun.")
return PLUGIN_HANDLED
}
give_item(id, GunsItem[item_index][Weapon_ID])
cs_set_user_bpammo(id, GunsItem[item_index][Weapon_Type], GunsItem[item_index][Weapon_Ammo])
}
cs_set_user_money(id, money)
printf(id, "^x04[BB Shop]^x01 You bought^x03 %s^x01 for^x04 %i$^x01.", GunsItem[item_index][Weapon_Fullname], GunsItem[item_index][Weapon_Cost])
return PLUGIN_HANDLED
}
public HealthMenu(id)
{
new item[64], num[3], menu
menu = menu_create("\rBB Shop\y |\w Zombie Items:", "health_handler")
for(new i = 0; i < sizeof(HealthItems); i++)
{
if(get_user_team(id) != HealthItems[i][Team])
continue
num_to_str(i, num, charsmax(num))
formatex(item, charsmax(item), "\y[\w%i HP\y]\r Rs:\w %i$", HealthItems[i][Health], HealthItems[i][Cost])
menu_additem(menu, item, num, 0)
}
if(menu_items(menu) <= 0)
{
printf(id, "^x04[BB Shop]^x01 No items were loaded for your category.")
return PLUGIN_HANDLED
}
menu_display(id, menu, 0)
return PLUGIN_HANDLED
}
public health_handler(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new access, num[3], callback, item_index, money
menu_item_getinfo(menu, item, access, num, charsmax(num), _, _, callback)
item_index = str_to_num(num)
money = cs_get_user_money(id) - HealthItems[item_index][Cost]
menu_destroy(menu)
if(money < 0)
{
printf(id, "^x04[BB Shop]^x01 You have insufficient money for this item.")
return PLUGIN_HANDLED
}
cs_set_user_money(id, money)
set_user_health(id, get_user_health(id) + HealthItems[item_index][Health])
printf(id, "^x04[BB Shop]^x01 You bought^x03 %i HP^x01 for^x04 %i$^x01.", HealthItems[item_index][Health], HealthItems[item_index][Cost])
return PLUGIN_HANDLED
}
// From internet, all of them
stock drop_primary_weapons(id)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for(i = 0; i < num; i++)
{
weaponid = weapons[i]
if(((1<<weaponid) & PRIMARY_WEAPONS_BITSUM))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
engclient_cmd(id, "drop", wname)
}
}
}
stock drop_secondary_weapons(id)
{
static weapons[32], num, i, weaponid
num = 0
get_user_weapons(id, weapons, num)
for(i = 0; i < num; i++)
{
weaponid = weapons[i]
if(((1<<weaponid) & SECONDARY_WEAPONS_BITSUM))
{
static wname[32]
get_weaponname(weaponid, wname, charsmax(wname))
engclient_cmd(id, "drop", wname)
}
}
}
printf(target, const message[], any:...)
{
static buffer[512], i, argscount
argscount = numargs()
// Send to everyone
if (!target)
{
static player
for (player = 1; player <= maxplayer; player++)
{
// Not connected
if (!is_user_connected(target))
continue;
// Remember changed arguments
static changed[5], changedcount // [5] = max LANG_PLAYER occurencies
changedcount = 0
// Replace LANG_PLAYER with player id
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
{
setarg(i, 0, player)
changed[changedcount] = i
changedcount++
}
}
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE_UNRELIABLE, saytext, _, player)
write_byte(player)
write_string(buffer)
message_end()
// Replace back player id's with LANG_PLAYER
for (i = 0; i < changedcount; i++)
setarg(changed[i], 0, LANG_PLAYER)
}
}
// Send to specific target
else
{
/*
// Not needed since you should set the ML argument
// to the player's id for a targeted print message
// Replace LANG_PLAYER with player id
for (i = 2; i < argscount; i++)
{
if (getarg(i) == LANG_PLAYER)
setarg(i, 0, target)
}
*/
// Format message for player
vformat(buffer, charsmax(buffer), message, 3)
// Send it
message_begin(MSG_ONE, saytext, _, target)
write_byte(target)
write_string(buffer)
message_end()
}
}