Well, I write /vipmenu ingame 3 times and then I get the menu. But it should block vipmenu until round 3. I don't know how to debug it
EDIT: The problem is that if I delete this cvar and wirte 3 insted of get_pcvar_num(vmr) it works.
PHP Code:
#define DAMAGE_RECIEVED
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <ammo_stocks>
#include <csx>
#include <stripweapons>
static const COLOR[] = "^x04" //green
static const CONTACT[] = ""
new maxplayers
new gmsgSayText
new mpd, mkb, mhb, mvt, vmr, mtr, mct, M4A1ammo, AK47ammo, AWPammo, DEAGLEammo, M4A1bpammo, AK47bpammo, AWPbpammo, DEAGLEbpammo
new g_MsgSync
new health_add
new health_hs_add
new health_max
new nKiller
new nKiller_hp
new nHp_add
new nHp_max
new round;
new szMap[ 20 ]
new gUsed[33]
new iPlayers[2];
#if defined DAMAGE_RECIEVED
new g_MsgSync2
#endif
new const vipmenu[][] =
{
"say /vipmenu", "say vipmenu"
}
new const mapnames[][] =
{
"awp_", "cs_deagle", "35hp_", "aim_"
}
public plugin_init()
{
register_plugin("VIP plugin", "3.4", "Evaldas.Grigas")
mpd = register_cvar("money_per_damage","3") // How much VIP gets money per damage
mkb = register_cvar("money_kill_bonus","200") // Hom much bonus VIP gets for kill
mhb = register_cvar("money_hs_bonus","500") // How much bonus VIP gets for head shot
mvt = register_cvar("max_vipmenu_times","3") // How much times VIP can use VIP menu per round
vmr = register_cvar("vip_menu_round","3") // From which round VIP can take VIP menu
mtr = register_cvar("minimum_tr","5") // How much player must be in T team, so VIP can take AWP choise
mct = register_cvar("minimum_ct","5") // How much player must be in CT team, so VIP can take AWP choise
health_add = register_cvar("amx_vip_hp", "5") // How much health VIP get for kill
health_hs_add = register_cvar("amx_vip_hp_hs", "10") // How much health VIP get for head shot
health_max = register_cvar("amx_vip_max_hp", "100") // How much VIP can have health
M4A1ammo = register_cvar("m4a1_ammo","30") // How much VIP gets M4A1 ammo
M4A1bpammo = register_cvar("m4a1_bammo","90") // How much VIP gets M4A1 bpammo
AK47ammo = register_cvar("ak47_pammo","30") // How much VIP gets AK47 ammo
AK47bpammo = register_cvar("ak47_bpammo","90") // How much VIP gets AK47 bpammo
AWPammo = register_cvar("awp_pammo","10") // How much VIP gets AWP ammo
AWPbpammo = register_cvar("awp_bpammo","30") // How much VIP gets AWP bpammo
DEAGLEammo = register_cvar("deagle_pammo","7") // How much VIP gets DEAGLE ammo
DEAGLEbpammo = register_cvar("deagle_bpammo","35") // How much VIP gets DEAGLE bpammo
register_clcmd("awp","HandleCmd")
register_clcmd("sg550","HandleCmd")
register_clcmd("g3sg1","HandleCmd")
register_event("Damage","Damage","b")
register_event("DeathMsg","death_msg","a")
register_event("ResetHUD", "resetModel", "b")
register_clcmd("say /vip","ShowMotd")
register_clcmd("say /vips","ShowVIP")
maxplayers = get_maxplayers()
gmsgSayText = get_user_msgid("SayText")
register_cvar("amx_contactinfo", CONTACT, FCVAR_SERVER)
RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost", 1)
register_event("TextMsg","Event_RoundRestart","a","2&#Game_w")
register_event("DeathMsg", "hook_death", "a", "1>0")
register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0")
g_MsgSync = CreateHudSyncObj()
#if defined DAMAGE_RECIEVED
g_MsgSync2 = CreateHudSyncObj()
#endif
for(new i = 0; i < sizeof vipmenu; i++)
register_clcmd(vipmenu[i], "cmdvipmenu")
get_mapname( szMap , charsmax( szMap ) );
}
public EventRoundStart( )
{
for( new i = 1; i < maxplayers; i++ )
{
if( is_user_connected(i) && is_user_alive( i ) && get_user_team(i) != 3 )
iPlayers[get_user_team(i) - 1]++;
}
}
public plugin_precache()
{
precache_model("models/player/adminash_ct/adminash_ct.mdl")
precache_model("models/player/adminash_t/adminash_t.mdl")
return PLUGIN_CONTINUE
}
public resetModel(id, level, cid)
{
if (get_user_flags(id) & ADMIN_LEVEL_H)
{
if (cs_get_user_team(id) == CS_TEAM_T)
{
cs_set_user_model(id, "adminash_t")
}
else if(cs_get_user_team(id) == CS_TEAM_CT)
{
cs_set_user_model(id, "adminash_ct")
}
else
{
cs_reset_user_model(id)
}
}
return PLUGIN_CONTINUE
}
public cmdvipmenu(id)
{
round++;
if (get_user_flags(id) & ADMIN_LEVEL_H)
{
if( gUsed[id] < get_pcvar_num(mvt) )
{
if ( is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H )
{
if( round >= get_pcvar_num(vmr) )
{
Showrod(id)
}
}
}
}
else
{
client_print(id, print_center, "[VIP] You don't have VIP! Write /vip, and you will see VIP privileges.")
}
return PLUGIN_HANDLED
}
public on_damage(id)
{
new attacker = get_user_attacker(id)
#if defined DAMAGE_RECIEVED
if ( is_user_connected(id) && is_user_connected(attacker) )
if (get_user_flags(attacker) & ADMIN_LEVEL_H)
{
new damage = read_data(2)
set_hudmessage(255, 0, 0, 0.45, 0.50, 2, 0.1, 4.0, 0.1, 0.1, -1)
ShowSyncHudMsg(id, g_MsgSync2, "%i^n", damage)
#else
if ( is_user_connected(attacker) && if (get_user_flags(attacker) & ADMIN_LEVEL_H) )
{
new damage = read_data(2)
#endif
set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
ShowSyncHudMsg(attacker, g_MsgSync, "%i^n", damage)
}
}
public Damage(id)
{
new weapon, hitpoint, attacker = get_user_attacker(id,weapon,hitpoint)
if(attacker<=maxplayers && is_user_alive(attacker) && attacker!=id)
if (get_user_flags(attacker) & ADMIN_LEVEL_H)
{
new money = read_data(2) * get_pcvar_num(mpd)
if(hitpoint==1) money += get_pcvar_num(mhb)
cs_set_user_money(attacker,cs_get_user_money(attacker) + money)
}
}
public death_msg()
{
if(read_data(1)<=maxplayers && read_data(1) && read_data(1)!=read_data(2)) cs_set_user_money(read_data(1),cs_get_user_money(read_data(1)) + get_pcvar_num(mkb) - 300)
}
public fwHamPlayerSpawnPost(id)
{
for( new i = 0 ; i < sizeof( mapnames ) ; i++ )
{
if ( equal( szMap , mapnames[ i ] ) )
return;
}
if(is_user_alive(id) && get_user_flags(id) & ADMIN_LEVEL_H)
{
StripWeapons(id, Secondary);
GiveClientWeapon(id, CSW_DEAGLE, false, get_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo));
give_item(id, "weapon_knife");
give_item(id, "weapon_hegrenade");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_flashbang");
give_item(id, "weapon_smokegrenade");
give_item(id, "item_assaultsuit");
give_item(id, "item_thighpack");
}
}
public Event_RoundRestart(id)
{
round=0;
}
public hook_death()
{
nKiller = read_data(1)
if ( (read_data(3) == 1) && (read_data(5) == 0) )
{
nHp_add = get_pcvar_num (health_hs_add)
}
else
nHp_add = get_pcvar_num (health_add)
nHp_max = get_pcvar_num (health_max)
if(!(get_user_flags(nKiller) & ADMIN_LEVEL_H))
return;
nKiller_hp = get_user_health(nKiller)
nKiller_hp += nHp_add
if (nKiller_hp > nHp_max) nKiller_hp = nHp_max
set_user_health(nKiller, nKiller_hp)
set_hudmessage(0, 255, 0, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1)
show_hudmessage(nKiller, "Healed +%d hp", nHp_add)
message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, nKiller)
write_short(1<<10)
write_short(1<<10)
write_short(0x0000)
write_byte(0)
write_byte(0)
write_byte(200)
write_byte(75)
message_end()
}
public Showrod(id)
{
for( new i = 0 ; i < sizeof( mapnames ) ; i++ )
{
if ( containi( szMap , mapnames[ i ] ) != -1 )
return;
}
set_task(10.0, "CancelMenu", id);
new menu = menu_create("\rVIP menu:", "Pressedrod");
menu_additem(menu, "\yM4A1 and Deagle.", "1", 0);
menu_additem(menu, "\yAK47 and Deagle.", "2", 0);
if( iPlayers[0] >= get_pcvar_num(mtr) && iPlayers[1] >= get_pcvar_num(mct) )
{
menu_additem(menu, "\yAWP and Deagle.", "3", 0);
}
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
menu_display(id, menu, 0);
}
public Pressedrod(id, menu, item)
{
if( item == MENU_EXIT )
{
menu_destroy(menu);
return PLUGIN_HANDLED;
}
new data[6], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1: {
StripWeapons(id, Primary);
StripWeapons(id, Secondary);
GiveClientWeapon(id, CSW_M4A1, false, get_pcvar_num(M4A1ammo), get_pcvar_num(M4A1bpammo))
GiveClientWeapon(id, CSW_DEAGLE, false, get_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
give_item(id,"weapon_knife");
give_item(id, "item_assaultsuit");
give_item(id, "item_thighpack");
client_print(id, print_center, "You have chosen M4A1 and Deagle!")
gUsed[id]++
}
case 2: {
StripWeapons(id, Primary);
StripWeapons(id, Secondary);
GiveClientWeapon(id, CSW_AK47, false, get_pcvar_num(AK47ammo), get_pcvar_num(AK47bpammo))
GiveClientWeapon(id, CSW_DEAGLE, false, get_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
give_item(id, "item_assaultsuit");
give_item(id, "item_thighpack");
client_print(id, print_center, "You have chosen AK47 and Deagle!")
gUsed[id]++
}
case 3: {
StripWeapons(id, Primary);
StripWeapons(id, Secondary);
GiveClientWeapon(id, CSW_AWP, false, get_pcvar_num(AWPammo), get_pcvar_num(AWPbpammo))
GiveClientWeapon(id, CSW_DEAGLE, false, get_pcvar_num(DEAGLEammo), get_pcvar_num(DEAGLEbpammo))
give_item(id, "item_assaultsuit");
give_item(id, "item_thighpack");
client_print(id, print_center, "You have chosen AWP and Deagle!")
gUsed[id]++
}
}
menu_destroy(menu);
return PLUGIN_CONTINUE
}
public CancelMenu(id)
{
show_menu(id, 0, "^n", 1);
}
public HandleCmd(id)
{
if(get_user_flags(id) & ADMIN_LEVEL_H)
return PLUGIN_CONTINUE
client_print(id, print_center, "Snipers only for VIP!")
return PLUGIN_HANDLED
}
public ShowMotd(id)
{
show_motd(id, "vip.txt")
}
public client_putinserver(id)
{
if (!task_exists(id)) set_task(60.0, "PrintText" ,id)
}
public PrintText(id)
{
client_print(id, print_chat, "[VIP] Write /vip, to see VIP privileges.")
}
public ShowVIP(id)
{
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
set_task(0.1,"print_adminlist",id)
}
return PLUGIN_CONTINUE
}
public print_adminlist(user, id)
{
if(get_user_flags(id) & ADMIN_LEVEL_H)
{
new adminnames[33][32]
new message[256]
new id, count, x, len
for(id = 1 ; id <= maxplayers ; id++)
if(is_user_connected(id))
if(get_user_flags(id) & ADMIN_LEVEL_H)
get_user_name(id, adminnames[count++], 31)
len = format(message, 255, "%sVIP online: ",COLOR)
if(count > 0)
{
for(x = 0 ; x < count ; x++)
{
len += format(message[len], 255-len, "%s%s ", adminnames[x], x < (count-1) ? ", ":"")
if(len > 96 )
{
print_message(user, message)
len = format(message, 255, "%s ",COLOR)
}
}
print_message(user, message)
}
else
{
len += format(message[len], 255-len, "There is no VIP online.")
print_message(user, message)
}
}
}
print_message(id, msg[])
{
message_begin(MSG_ONE, gmsgSayText, {0,0,0}, id)
write_byte(id)
write_string(msg)
message_end()
}