When I buy super knife or super knife vip from the shop if I take the grenade in my hand or anything else the item disappears
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <engine>
#include <fakemeta_util>
#define PLUGIN_NAME "Furien Shop"
#define PLUGIN_VERSION "1.0"
#define PLUGIN_AUTHOR "AlliedMods"
#define FURIEN_VIP ADMIN_LEVEL_H
new has_no_flash[33]
new has_model[33]
new const models[][] = { "models/v_knife_human.mdl", "models/v_superknifeVIP.mdl" }
new g_msgScreenFade
new const prefix[] = { "!g[!tShop!g]!n" }
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_clcmd("say /shop", "shop")
register_clcmd("say_team /shop", "shop")
register_event("CurWeapon","switchweapon","be","1=1","2!29")
register_event("DeathMsg", "deathmsg", "a");
register_event("ScreenFade", "eventFlash", "be", "4=255", "5=255", "6=255", "7>199")
g_msgScreenFade = get_user_msgid("ScreenFade")
}
public deathmsg(){
new ivictim = read_data(2);
has_no_flash[ivictim] = false;
has_model[ivictim]=false;
}
public switchweapon(id)
{
if(is_user_alive(id) && has_model[id])
if(get_user_weapon( id ) == CSW_KNIFE)
set_pev(id, pev_viewmodel2, get_user_flags(id) & FURIEN_VIP ? models[1] : models[0] )
}
public client_disconnect(id){
has_no_flash[id] = false;
has_model[id]=false;
}
public client_connect(id){
has_no_flash[id] = false;
has_model[id]=false;
}
public plugin_precache() {
precache_model(models[0])
precache_model(models[1])
}
public eventFlash(id)
{
if(has_no_flash[id])
{
message_begin(MSG_ONE, g_msgScreenFade, {0,0,0}, id)
write_short(1)
write_short(1)
write_short(1)
write_byte(0)
write_byte(0)
write_byte(0)
write_byte(255)
message_end()
}
}
public shop(id)
{
if(!is_user_alive(id))
{
client_printc(id, "%s You !gmust !nbe !talive !nto !topen !nthe !gShop!n!", prefix);
return PLUGIN_HANDLED
}
switch(cs_get_user_team(id))
{
case CS_TEAM_CT:
AFURIEN(id);
case CS_TEAM_T:
FURIEN(id);
}
return PLUGIN_HANDLED;
}
public FURIEN(id)
{
if(!is_user_alive(id))
{
client_printc(id, "%s You !gmust !nbe !talive !nto !topen !nthe !gShop!n!", prefix);
return PLUGIN_HANDLED
}
new menu = menu_create("FURIEN Shop", "shop_furien");
menu_additem(menu, "Super Knife [10000$] ", "1", 0);
menu_additem(menu, "HE Grenade [3000$] ", "2", 0);
menu_additem(menu, "+50 Health [3000$] ", "3", 0);
menu_additem(menu, "+50 Armor [500$] ", "4", 0);
menu_additem(menu, "No Flash [1000$] ", "5", 0);
menu_additem(menu, "Super Knife VIP ", "6", 0);
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
return PLUGIN_HANDLED
}
public shop_furien(id, menu, item)
{
if(!is_user_alive(id))
{
client_printc(id, "%s You !gmust !nbe !talive !nto !topen !nthe !gShop!n!", prefix);
return PLUGIN_HANDLED
}
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
new tmp_money = cs_get_user_money(id)
switch(key)
{
case 1:
{
if(tmp_money < 10000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
has_model[id]=true;
if(get_user_weapon( id ) == CSW_KNIFE)
set_pev(id, pev_viewmodel2, models[0])
cs_set_user_money(id, tmp_money - 10000)
client_printc(id, "%s You bought !gSuper Knife!", prefix);
}
case 2:
{
if(tmp_money < 3000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
if(user_has_weapon(id, CSW_HEGRENADE))
{
client_printc(id, "%s You already have !gHeGrenade!", prefix);
return PLUGIN_HANDLED;
}
give_item(id, "weapon_hegrenade")
cs_set_user_money(id, tmp_money - 3000)
client_printc(id, "%s You bought !gHE Grenade!", prefix);
}
case 3:
{
if(tmp_money < 3000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
new health = get_user_health(id);
if(health >= 200){
client_printc(id, "%s You cant have more than !g200 Health!", prefix);
return PLUGIN_HANDLED;
}
health+=50;
set_user_health(id, clamp(health,0,200) == 200 ? 200 : health)
cs_set_user_money(id, tmp_money - 3000)
client_printc(id, "%s You bought !g+50 HP!", prefix);
}
case 4:
{
if(tmp_money < 500)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
new armor = get_user_armor(id);
if(armor >= 300){
client_printc(id, "%s You cant have more than !g300 Armor!", prefix);
return PLUGIN_HANDLED;
}
armor+=50
set_user_armor(id, clamp(armor,0,300) == 300 ? 300 : armor)
cs_set_user_money(id, tmp_money - 500)
client_printc(id, "%s You bought !g+50 AP!", prefix);
}
case 5:
{
if(tmp_money < 1000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
has_no_flash[id]=true;
cs_set_user_money(id, tmp_money - 1000)
client_printc(id, "%s You bought !gNo Flash!", prefix);
}
case 6:
{
if(get_user_flags(id) & FURIEN_VIP)
{
client_printc(id, "%s You taked !gSuper Knife VIP!", prefix);
has_model[id]=true;
if(get_user_weapon( id ) == CSW_KNIFE)
set_pev(id, pev_viewmodel2, models[1])
}
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public AFURIEN(id)
{
if(!is_user_alive(id))
{
client_printc(id, "%s You !gmust !nbe !talive !nto !topen !nthe !gShop!n!", prefix);
return PLUGIN_HANDLED
}
new menu = menu_create("Anti-Furien Shop", "shop_afurien");
menu_additem(menu, "Defuse Kit [500$] ", "1", 0);
menu_additem(menu, "HE Grenade [3000$] ", "2", 0);
menu_additem(menu, "+50 Health [3000$] ", "3", 0);
menu_additem(menu, "+50 Armor [500$] ", "4", 0);
menu_additem(menu, "No Flash [10000$] ", "5", 0);
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
return PLUGIN_HANDLED
}
public shop_afurien(id, menu, item)
{
if(!is_user_alive(id))
{
client_printc(id, "%s You !gmust !nbe !talive !nto !topen !nthe !gShop!n!", prefix);
return PLUGIN_HANDLED
}
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], iName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data);
new tmp_money = cs_get_user_money(id)
switch(key)
{
case 1:
{
if(tmp_money < 500)
{
client_printc(id, "%s Nu ai destui !gBani!", prefix);
return PLUGIN_HANDLED;
}
if(cs_get_user_defuse(id))
{
client_printc(id, "%s You already have !gDefuse Kit!", prefix);
return PLUGIN_HANDLED;
}
cs_set_user_money(id, tmp_money - 500)
give_item(id, "item_thighpack");
give_item(id, "item_assaultsuit");
client_printc(id, "%s You bought !gDefuse Kit!", prefix);
}
case 2:
{
if(tmp_money < 3000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
if(user_has_weapon(id, CSW_HEGRENADE))
{
client_printc(id, "%s You already have !gHeGrenade!", prefix);
return PLUGIN_HANDLED;
}
give_item(id, "weapon_hegrenade")
cs_set_user_money(id, tmp_money - 3000)
client_printc(id, "%s You bought !gHE Grenade!", prefix);
}
case 3:
{
if(tmp_money < 3000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
new health = get_user_health(id);
if(health >= 200){
client_printc(id, "%s You cant have more than !g200 Health!", prefix);
return PLUGIN_HANDLED;
}
health+=50;
set_user_health(id, clamp(health,0,200) == 200 ? 200 : health)
cs_set_user_money(id, tmp_money - 3000)
client_printc(id, "%s You bought !g+50 HP!", prefix);
}
case 4:
{
if(tmp_money < 500)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
new armor = get_user_armor(id);
if(armor >= 300){
client_printc(id, "%s You cant have more than !g300 Armor!", prefix);
return PLUGIN_HANDLED;
}
armor+=50
set_user_armor(id, clamp(armor,0,300) == 300 ? 300 : armor);
cs_set_user_money(id, tmp_money - 500)
client_printc(id, "%s You bought !g+50 AP!", prefix);
}
case 5:
{
if(tmp_money < 1000)
{
client_printc(id, "%s You dont have enough !gMoney!", prefix);
return PLUGIN_HANDLED;
}
has_no_flash[id]=true;
cs_set_user_money(id, tmp_money - 1000)
client_printc(id, "%s You bought !gNo Flash!", prefix);
}
}
menu_destroy(menu);
return PLUGIN_HANDLED;
}
stock client_printc(const id, const input[], any:...)
{
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!g", "^x04"); // Green Color
replace_all(msg, 190, "!n", "^x01"); // Default Color
replace_all(msg, 190, "!t", "^x03"); // Team Color
if(id)
players[0] = id;
else
get_players(players, count, "ch");
for (new i = 0; i < count; i++)
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}