I need some help . This code works sorta . I get run time errors. It finds the bomb perfectly. But for some reason it executes my code on CT's , but in reverse of the T's. for instance , it shows the essage to CT's get within 1000 units of the bomb. but T's it works for , but it doesnt do any of the punishments. I cant figure out if its my flags or the functions .
Code:
#include <amxmodx>
#include <engine>
#include <fun>
// Global Variables
new g_iFollow_Bomb;
new g_iPunish,Player_Count;
new g_iRadius;
new g_iEntlist[513];
new g_iPlayers[32];
new g_Mode[8];
// register plugin
public plugin_init()
{
register_plugin("Follow The Bomber","0.1","The Speicialist");
register_event("ResetHUD","reset_hud","be");
g_iFollow_Bomb = register_cvar("amx_follow_bomb","1");
g_iPunish = register_cvar("amx_punishment","ab");
g_iRadius = register_cvar("amx_radius","1000");
set_task(2.0,"find_bomb",0,"",0,"b");
}
// reset hud event
public reset_hud(id)
{
// show message to follwo the bomb
set_hudmessage(255, 255, 255, -1.0, 0.38, 0, 6.0, 12.0);
show_hudmessage(id, "Follow The Bomb");
}
// find bomb and players in and out of range
public find_bomb(id)
{
// find the bomb
new g_iBomb = find_ent_by_class(-1,"weapon_c4");
// if cvar is off OR if there is no bomb end function
if(get_pcvar_num(g_iFollow_Bomb)==0 || g_iBomb == 0)
{
return PLUGIN_HANDLED;
}else{
// find players in the radious sphere of the bomb
new g_In_Range = find_sphere_class(g_iBomb,"player",get_pcvar_float(g_iRadius),g_iEntlist,512);
// find all alive terrorists
new g_All_Players = get_players(g_iPlayers,Player_Count,"ace","CS_TEAM_T");
// if all alive terrorists arnt in range then punish
if(g_All_Players != g_In_Range)
{
punish_mode(id);
}
}
return PLUGIN_HANDLED;
}
// punishment function
public punish_mode(id)
{
// get string for cvars
get_pcvar_string(g_iPunish,g_Mode,7);
// read flags from string cvar
new g_iMode = read_flags(g_Mode);
new g_iArmor = get_user_armor(id);
// dispaly hud messages for leaving bomb
set_hudmessage(255, 255, 255, -1.0, 0.34, 0, 6.0, 2.0);
show_hudmessage(id, "Your Leaving The Bomb");
// punish based on flags from cvar string
if(g_iMode == 1 )
{
// slap with -1 haelth but dont move
user_slap(id,1,0);
}
if(g_iMode ==2 )
{
// -1 armor from user
set_user_armor(id,(g_iArmor - 1));
}
if(g_iMode == 4 )
{
// strip the weapons from that user
strip_user_weapons(id);
}
return PLUGIN_HANDLED;
}