so i want if someone types say buy ma5b you get a p90 with halo p90 model but if you drop the p90 you lose the has_ma5b and you have to say buy ma5b again to get the halo p90
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
new bool:has_ma5b[33]
new ma5b_ent[33]
public plugin_init() {
register_plugin("Halo Models", "0.1", "Front Line")
register_concmd("say buy ma5b","buy_ma5b")
register_cvar("ma5b_cost","4000")
register_event("ResetHUD", "resetModel", "b")
register_event("CurWeapon", "halo_gun", "be", "1=1")
register_event("ResetHUD", "resethud_event", "b")
register_event("DeathMsg", "death_event", "a")
return PLUGIN_CONTINUE
}
public plugin_precache() {
precache_model("models/player/halo_t/halo_t.mdl")
precache_model("models/player/halo_ct/halo_ct.mdl")
precache_model("models/v_halogun.mdl")
precache_model("models/p_halogun.mdl")
precache_model("models/w_halogun.mdl")
precache_sound("weapons/p90-1.wav")
precache_sound("weapons/p90_clipin.wav")
precache_sound("weapons/p90_boltpull.wav")
precache_sound("weapons/p90_clipout.wav")
precache_sound("weapons/p90_cliprelease.wav")
precache_sound("weapons/p90_draw.wav")
return PLUGIN_CONTINUE
}
public client_connect(id)
{
if(ma5b_ent[id] > 0)
{
remove_entity(ma5b_ent[id])
}
has_ma5b[id] = false
ma5b_ent[id] = 0
}
public resetModel(id) {
if (cs_get_user_team(id) == CS_TEAM_T) {
cs_set_user_model(id, "halo_t")
}
else if(cs_get_user_team(id) == CS_TEAM_CT) {
cs_set_user_model(id, "halo_ct")
}
return PLUGIN_CONTINUE
}
public resethud_event(id)
{
if(ma5b_ent[id] > 0)
{
remove_entity(ma5b_ent[id])
ma5b_ent[id] = 0
}
}
public death_event()
{
new id = read_data(2)
if(ma5b_ent[id] > 0)
{
remove_entity(ma5b_ent[id])
}
has_ma5b[id] = false
ma5b_ent[id] = 0
}
public buy_ma5b(id) {
if(has_ma5b[id])
{
client_print(id,print_chat,"[AMXX] You already have a m5ab")
return PLUGIN_HANDLED
}
new money = cs_get_user_money(id)
new cost = get_cvar_num("ma5b_cost")
if (money < cost)
{
client_print(id, print_chat, "[AMXX] You don't have enough money ($%i needed).", cost)
return PLUGIN_CONTINUE
}
cs_set_user_money(id, money - cost)
client_print(id, print_chat,"[AMXX] You have bought a ma5b.")
has_ma5b[id] = true
give_item(id,"weapon_p90")
return PLUGIN_CONTINUE
}
public halo_gun(id) {
new weapons[32],wnum, ok = 1
get_user_weapons(id,weapons,wnum)
for(new i = 0; i < wnum; i++) {
if(weapons[i] == CSW_P90) {
if(ok == 0) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_p90.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_hp90.mdl")
}else if(ok == 1) {
entity_set_string(id, EV_SZ_viewmodel, "models/v_halogun.mdl")
entity_set_string(id, EV_SZ_weaponmodel, "models/p_halogun.mdl")
}
}
}
}