Just because I was bored. There are several other optimizations that can be made, but did a few for you. Note that I also changed the model path for the player models in order for them to work correctly.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <engine>
#include <colorchat>
#include <fakemeta>
#define PLUGIN "HideNSeek Market"
#define VERSION "1.0.5"
#define AUTHOR "BunnYboii"
new g_szPrefix[] = "^04[HideNSeek Market]^01"
new const gszTransformSound[] = "zombie_plauge/zombie_infec3.wav"
new VIEW_MODEL[] = "models/v_zombieknife.mdl"
new WORLD_MODEL[] = "models/v_zombieknife.mdl"
new ZOMBIE[] = "models/player/bg_zombie/bg_zombie.mdl"
new CTs[] = "models/player/ct/ct.mdl"
new Ts[] = "models/player/t/t.mdl"
enum _:Item
{
HE,
Flash,
Frost,
Scout,
Deagle,
AWP,
Fiveseven,
Zombie,
CT,
T
};
new const Name[ Item ][ ] =
{
"HE Grenade",
"Flashbang",
"Frost Nade",
"Scout",
"Deagle",
"AWP",
"Fiveseven",
"Zombie Class",
"CT Class",
"T Class"
};
new const Cost[ Item ] =
{
300,
400,
600,
800,
1000,
1400,
700,
1500,
1700,
1900
};
new pScout, pDeagle, pAwp, pFiveSeven
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /market", "mod_menu")
register_clcmd("say /shop", "mod_menu")
register_clcmd("say /hm", "mod_menu")
register_clcmd("say /info", "show_info")
// Amount of ammo on weapons
pScout = register_cvar("s_scout_ammo", "0")
pDeagle = register_cvar("s_dgl_ammo", "1")
pAwp = register_cvar("s_awp_ammo", "1")
pFiveSeven = register_cvar("s_fs_ammo", "2")
register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
register_forward(FM_SetModel, "fw_setModel")
}
public show_info(id)
{
ColorChat(id, TEAM_COLOR, "%s This plugin is made by BunnYboii ^x03[Version: 1.0.5]^x01", g_szPrefix)
}
public plugin_precache()
{
precache_model(VIEW_MODEL)
precache_model(WORLD_MODEL)
precache_model(ZOMBIE)
precache_model(CTs)
precache_model(Ts)
precache_sound(gszTransformSound)
}
public mod_menu(id)
{
if(get_user_flags(id) & ( ADMIN_ADMIN | ADMIN_KICK ) )
{
new menu = menu_create("\w[HideNSeek \yMarket\w]", "menu_handler");
new Text[ 128 ], Num[ 3 ];
for( new Index; Index < Item; Index++ )
{
num_to_str( Index, Num, charsmax( Num ) );
formatex( Text, charsmax( Text ), "\w%s [\r%i$\w]", Name[ Index ], Cost[ Index ] );
menu_additem( menu, Text, Num );
}
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0)
}
else
{
ColorChat(id, TEAM_COLOR, "%s You have no ^04access^01 this menu.", g_szPrefix)
}
}
public menu_handler(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
if(!is_user_alive(id))
{
return PLUGIN_HANDLED;
}
new data[2];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), _, _, callback);
new key = str_to_num(data)
new money = cs_get_user_money(id)
if( money >= Cost[ key ] )
{
switch( key )
{
case Zombie, CT:
{
if( cs_get_user_team( id ) != CS_TEAM_CT )
{
ColorChat(id, TEAM_COLOR, "%s You need to be a ^03CT^01 to buy this!", g_szPrefix)
return PLUGIN_HANDLED;
}
}
case T:
{
if( cs_get_user_team( id ) != CS_TEAM_T )
{
ColorChat(id, TEAM_COLOR, "%s You need to be a ^03T^01 to buy this!", g_szPrefix)
return PLUGIN_HANDLED;
}
}
}
new setmoney = money - Cost[ key ]
cs_set_user_money(id, clamp(setmoney, 0, 16000))
Give( id, key );
}
else
{
ColorChat(id, TEAM_COLOR, "%s You have insufficient funds!", g_szPrefix)
}
return PLUGIN_HANDLED;
}
Give( id, item )
{
switch( item )
{
case HE:
{
give_item(id, "weapon_hegrenade")
ColorChat(id, TEAM_COLOR, "%s You bought a HE Grenade.", g_szPrefix)
}
case Flash:
{
give_item(id, "weapon_flashbang")
ColorChat(id, TEAM_COLOR, "%s You bought a Flashbang.", g_szPrefix)
}
case Frost:
{
give_item(id, "weapon_smokegrenade")
ColorChat(id, TEAM_COLOR, "^%s You bought a Frostnade!", g_szPrefix)
}
case Scout:
{
new weapon_id = give_item(id, "weapon_scout");
cs_set_weapon_ammo(weapon_id, get_pcvar_num(pScout))
ColorChat(id, TEAM_COLOR, "%s You bought Scout.", g_szPrefix)
}
case Deagle:
{
new weapon_id = give_item(id, "weapon_deagle");
cs_set_weapon_ammo(weapon_id, get_pcvar_num(pDeagle))
ColorChat(id, TEAM_COLOR, "%s You bought a Deagle.", g_szPrefix)
}
case AWP:
{
new weapon_id = give_item(id, "weapon_awp");
cs_set_weapon_ammo(weapon_id, get_pcvar_num(pAwp))
ColorChat(id, TEAM_COLOR, "%s You bought an AWP.", g_szPrefix)
}
case Fiveseven:
{
new weapon_id = give_item(id, "weapon_fiveseven");
cs_set_weapon_ammo(weapon_id, get_pcvar_num(pFiveSeven))
ColorChat(id, TEAM_COLOR, "%s You bought a FiveSeven.", g_szPrefix)
}
case Zombie:
{
set_pev(id, pev_viewmodel2, VIEW_MODEL)
cs_set_user_model(id, "bg_zombie")
set_user_gravity(id, 0.75)
emit_sound(id, CHAN_STATIC, gszTransformSound, 1.0, ATTN_NORM, 0, PITCH_NORM);
ColorChat(id, TEAM_COLOR, "%s You bought the Zombie class.", g_szPrefix)
}
case CT:
{
cs_set_user_model(id, "ct")
ColorChat(id, TEAM_COLOR, "%s You bought the CT's class", g_szPrefix)
}
case T:
{
cs_set_user_model(id, "t")
ColorChat(id, TEAM_COLOR, "%s You bougt the T's class", g_szPrefix)
}
}
}