Код за потвърждение: Избери целия код
#include <amxmodx>
#include <cromchat>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
//#define USING_REAPI
#define REPLACE_OLD_WEAPONS
#if defined USING_REAPI
#include <reapi>
#else
#if defined REPLACE_OLD_WEAPONS
#include <stripweapons>
#endif
#endif
#define PLUGIN_VERSION "1.0"
#define SOUND_BUY "items/gunpickup2.wav"
#define NO_WEAPON -1
enum _:ItemInfo
{
Name[32],
Price,
Weapon[16],
Ammo,
Csw,
VModel[32],
PModel[32],
CsTeams:Team
}
new const g_eItems[][ItemInfo] =
{
/* "Name", Price, "weapon_id", Bullets, CSW_ID, "v_model", "p_model", "team" */
{ "Golden Deagle", 5000, "weapon_deagle", 35, CSW_DEAGLE, "models/v_deagle.mdl", "models/p_deagle.mdl", CS_TEAM_CT },
{ "Golden M4A1", 10000, "weapon_m4a1", 90, CSW_M4A1, "models/v_m4a1.mdl", "models/p_m4a1.mdl", CS_TEAM_CT },
{ "Golden Glock", 5000, "weapon_glock18", 30, CSW_GLOCK18, "models/v_glock18.mdl", "models/p_glock18.mdl", CS_TEAM_T },
{ "Golden AK47", 10000, "weapon_ak47", 90, CSW_AWP, "models/v_ak47.mdl", "models/p_ak47.mdl", CS_TEAM_T },
{ "Golden AWP", 16000, "weapon_awp", 30, CSW_AWP, "models/v_awp.mdl", "models/p_awp.mdl", CS_TEAM_CT|CS_TEAM_T }
}
new g_iWeapon[33]
public plugin_init()
{
register_plugin("Golden Shop", PLUGIN_VERSION, "OciXCrom")
register_cvar("CRXGoldenShop", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
register_event("CurWeapon", "OnChangeWeapon", "be", "1=1")
RegisterHam(Ham_Spawn, "player", "OnPlayerSpawn", 1)
RegisterHam(Ham_TakeDamage, "player", "PreTakeDamage", 0)
register_clcmd("say /gold", "Cmd_Shop")
register_clcmd("say_team /gold", "Cmd_Shop")
CC_SetPrefix("[&x04GOLD&x01]")
}
public plugin_precache()
{
precache_sound(SOUND_BUY)
for(new i; i < sizeof(g_eItems); i++)
{
if(g_eItems[i][VModel][0])
precache_model(g_eItems[i][VModel])
if(g_eItems[i][PModel][0])
precache_model(g_eItems[i][PModel])
}
}
public client_putinserver(id)
g_iWeapon[id] = NO_WEAPON
public OnPlayerSpawn(id)
g_iWeapon[id] = NO_WEAPON
public PreTakeDamage(iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits)
{
if(g_iWeapon[iAttacker] != NO_WEAPON)
SetHamParamFloat(4, fDamage * 2)
}
public OnChangeWeapon(id)
{
if(g_iWeapon[id] == NO_WEAPON || read_data(2) != g_eItems[g_iWeapon[id]][Csw])
return
if(g_eItems[g_iWeapon[id]][VModel][0])
set_pev(id, pev_viewmodel2, g_eItems[g_iWeapon[id]][VModel])
if(g_eItems[g_iWeapon[id]][PModel][0])
set_pev(id, pev_weaponmodel2, g_eItems[g_iWeapon[id]][PModel])
}
public Cmd_Shop(id)
{
if(!is_user_alive(id))
CC_SendMessage(id, "You need to be alive.")
else
{
new iMenu = menu_create("\rGold Shop", "Shop_Handler")
new szItem[64], iMoney = cs_get_user_money(id)
for(new szKey[4], CsTeams:iTeam = cs_get_user_team(id), i; i < sizeof(g_eItems); i++)
{
if(g_eItems[i][Team] & iTeam)
{
if(g_iWeapon[id] == i)
formatex(szItem, charsmax(szItem), "\d%s \y[OWNED]", g_eItems[i][Name])
else
formatex(szItem, charsmax(szItem), "%s%s \r[%i$]", iMoney >= g_eItems[i][Price] ? "\w" : "\d", g_eItems[i][Name], g_eItems[i][Price])
num_to_str(i, szKey, charsmax(szKey))
menu_additem(iMenu, szItem, szKey)
}
}
menu_display(id, iMenu)
}
return PLUGIN_HANDLED
}
public Shop_Handler(id, iMenu, iItem)
{
if(iItem != MENU_EXIT && is_user_alive(id))
{
new szKey[4], iUnused
menu_item_getinfo(iMenu, iItem, iUnused, szKey, charsmax(szKey), .callback = iUnused)
new iKey = str_to_num(szKey)
if(g_iWeapon[id] == iKey)
CC_SendMessage(id, "You already have this item.")
else
{
new iMoney = cs_get_user_money(id)
if(iMoney < g_eItems[iKey][Price])
CC_SendMessage(id, "You don't have enough money to purchase this item.")
else
{
cs_set_user_money(id, iMoney - g_eItems[iKey][Price])
CC_SendMessage(id, "You have bought ^3%s ^1for ^4%i$", g_eItems[iKey][Name], g_eItems[iKey][Price])
emit_sound(id, CHAN_ITEM, SOUND_BUY, 1.0, ATTN_NORM, 0, PITCH_NORM)
g_iWeapon[id] = iKey
#if defined USING_REAPI
#if defined REPLACE_OLD_WEAPONS
rg_give_item(id, g_eItems[iKey][Weapon], GT_REPLACE)
#else
rg_give_item(id, g_eItems[iKey][Weapon], GT_APPEND)
#endif
#else
#if defined REPLACE_OLD_WEAPONS
StripWeapons(id, Primary)
#endif
give_item(id, g_eItems[iKey][Weapon])
#endif
cs_set_user_bpammo(id, g_eItems[iKey][Csw], g_eItems[iKey][Ammo])
OnChangeWeapon(id)
}
}
}
menu_destroy(iMenu)
return PLUGIN_HANDLED
}