so...i have this plugin
i've tried to make it set a cvar's value to 7 on round end and then restore it on round start (variable nvg_radius)
but it doesn't work...it doesn't set the radius back to normal on round start
and the second problem is that sometimes, the hand model doesn't change back on round start either
here's the code...please help
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
new Hands[33], Random, MaxPlayers, ChekUserHands, SetNVision
// Normal Models
new const MODELS[3][] =
{
"",
"models/zombie_plague/zombie_win.mdl",
"models/zombie_plague/human_win.mdl"
}
new const MODELS2[3][] =
{
"",
"models/zombie_plague/zombie_win_2.mdl",
"models/zombie_plague/human_win_2.mdl"
}
// Fliped Models
new const MODELS_FLIP[3][] =
{
"",
"models/zombie_plague/zombie_win-f.mdl",
"models/zombie_plague/human_win-f.mdl"
}
new const MODELS_FLIP2[3][] =
{
"",
"models/zombie_plague/zombie_win-f_2.mdl",
"models/zombie_plague/human_win-f_2.mdl"
}
new g_iModelIndex[3], g_iModelIndexFlip[3], g_iModelIndex2[3], g_iModelIndexFlip2[3], g_iWinTeam, nvg_radius
public plugin_init()
{
register_plugin("[ZP] Sub-Plugin: New Win Messages", "1.4", "Shidla / xPaw / 93()|29!/<" )
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0" )
register_event("CurWeapon", "EventCurWeapon", "be", "1=1")
MaxPlayers = get_maxplayers()
register_cvar("Shidla", "[ZP] Sub-Plugin: New Win Messages v.1.4", FCVAR_SERVER|FCVAR_SPONLY)
register_cvar("zp_new_win_messages", "[ZP] Sub-Plugin: New Win Messages v.1.4", FCVAR_SERVER|FCVAR_SPONLY)
ChekUserHands = register_cvar("zp_new_win_msg_chek" , "1")
SetNVision = register_cvar("zp_new_win_msg_set_nvision" , "1")
}
public plugin_precache()
{
for (new i = WIN_ZOMBIES; i <= WIN_HUMANS; i++)
{
// Normal Models
precache_model(MODELS[i])
g_iModelIndex[i] = engfunc(EngFunc_AllocString, MODELS[i])
precache_model(MODELS2[i])
g_iModelIndex2[i] = engfunc(EngFunc_AllocString, MODELS2[i])
// Fliped Models
precache_model(MODELS_FLIP[i])
g_iModelIndexFlip[i] = engfunc(EngFunc_AllocString, MODELS_FLIP[i])
precache_model(MODELS_FLIP2[i])
g_iModelIndexFlip2[i] = engfunc(EngFunc_AllocString, MODELS_FLIP2[i])
}
}
public client_connect(id)
{
if(!is_user_bot(id) && get_pcvar_num (ChekUserHands))
query_client_cvar(id , "cl_righthand" , "Hands_CVAR_Value")
}
public Hands_CVAR_Value(id, const cvar[], const value[])
{
if((1 <= id <= MaxPlayers) && get_pcvar_num (ChekUserHands)) // Bug Fix & Cheking
Hands[id] = str_to_num(value)
}
public client_disconnect(id)
{
if(get_pcvar_num (ChekUserHands))
Hands[id] = 0
}
public zp_round_ended(iTeam)
{
if (iTeam == WIN_NO_ONE)
return
g_iWinTeam = iTeam
new iPlayers[32], iNum
get_players(iPlayers, iNum, "ch")
Random = random_num(0 , 1)
for (new i; i < iNum; i++)
{
if(get_pcvar_num (ChekUserHands))
client_cmd(iPlayers[i], "cl_righthand ^"1^"")
if(get_pcvar_num(SetNVision))
{
nvg_radius = get_cvar_num("zp_nvg_size")
set_cvar_num("zp_nvg_size", 7)
zp_set_user_nightvision(iPlayers[i], 1)
}
switch(Random)
{
case 0:
{
if (get_user_weapon(iPlayers[i]) != CSW_KNIFE)
set_pev(iPlayers[i], pev_viewmodel, g_iModelIndexFlip[iTeam])
else
set_pev(iPlayers[i], pev_viewmodel, g_iModelIndex[iTeam])
}
case 1:
{
if (get_user_weapon(iPlayers[i]) != CSW_KNIFE)
set_pev(iPlayers[i], pev_viewmodel, g_iModelIndexFlip2[iTeam])
else
set_pev(iPlayers[i], pev_viewmodel, g_iModelIndex2[iTeam])
}
}
}
}
public EventRoundStart()
{
g_iWinTeam = WIN_NO_ONE
if (get_cvar_num("zp_nvg_size") != nvg_radius)
set_cvar_num("zp_nvg_size", nvg_radius)
if(get_pcvar_num (ChekUserHands))
{
for (new i = 1; i <= MaxPlayers; i++)
{
if(!is_user_connected(i))
continue // xPaw fix)))
client_cmd(i, "cl_righthand ^"%d^"", Hands[i])
}
}
}
public EventCurWeapon(const id)
{
if (g_iWinTeam > WIN_NO_ONE)
{
if (get_pcvar_num (ChekUserHands))
client_cmd(id, "cl_righthand ^"1^"")
switch(Random)
{
case 0:
{
if (get_user_weapon(id) != CSW_KNIFE)
set_pev(id, pev_viewmodel, g_iModelIndexFlip[g_iWinTeam])
else
set_pev(id, pev_viewmodel, g_iModelIndex[g_iWinTeam])
}
case 1:
{
if (get_user_weapon(id) != CSW_KNIFE)
set_pev(id, pev_viewmodel, g_iModelIndexFlip2[g_iWinTeam])
else
set_pev(id, pev_viewmodel, g_iModelIndex2[g_iWinTeam])
}
}
}
}