thanks for replying, actually i did add the sqroot to the equation infact here's the full code...
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#define PLUGIN "Health circle"
#define VERSION "1.0"
#define AUTHOR "Natsheh"
new g_sprite;
#define X 0
#define Y 1
#define Z 2
public plugin_precache() g_sprite = precache_model("sprites/laserbeam.spr");
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("amx_health_circle", "handler_command", ADMIN_KICK, "<rad> <width> <axis x> <axis y> <axis z>");
register_clcmd("amx_delete_health_circle", "handler_command2", ADMIN_KICK, "remove health circle nearby!");
register_think("health_circle", "brain_work");
}
public handler_command2(id, level, cid)
{
if(!cmd_access(id, level, cid, 1)) return 1;
new ent = -1, target_circle = 0, Float:wanted_distance = 250.0, Float:fOrigin[3], Float:fOrigin2[3], Float:z;
pev(id, pev_origin, fOrigin);
while( (ent = find_ent_by_class(ent, "health_circle")) > 0 )
{
pev(ent, pev_origin, fOrigin2);
if( (z=get_distance_f(fOrigin, fOrigin2)) <= wanted_distance )
{
target_circle = ent; wanted_distance = z;
}
}
if(target_circle > 0)
{
set_entity_flags(target_circle, FL_KILLME, true);
console_print(id, "The health circle nearby was removed!");
}
else
{
console_print(id, "No health circles were found!");
}
return 1;
}
public handler_command(id, level, cid)
{
if(!cmd_access(id, level, cid, 2)) return 1;
new szRadius[5], szWidth[5], szAngle_X[5], szAngle_Y[5], szAngle_Z[5];
read_argv(1, szRadius, charsmax(szRadius));
read_argv(2, szWidth, charsmax(szWidth));
read_argv(3, szAngle_X, charsmax(szAngle_X));
read_argv(4, szAngle_Y, charsmax(szAngle_Y));
read_argv(5, szAngle_Z, charsmax(szAngle_Z));
remove_quotes(szRadius);
remove_quotes(szWidth);
remove_quotes(szAngle_X);
remove_quotes(szAngle_Y);
remove_quotes(szAngle_Z);
new ent = create_entity("info_target");
if(ent > 0)
{
entity_set_string(ent, EV_SZ_classname, "health_circle");
new Float:fAngles[3];
entity_get_vector(id, EV_VEC_origin, fAngles);
entity_set_origin(ent, fAngles);
entity_set_int(ent, EV_INT_iuser4, str_to_num(szWidth));
entity_set_float(ent, EV_FL_fuser4, floatstr(szRadius));
fAngles[0] = floatstr(szAngle_X);
fAngles[1] = floatstr(szAngle_Y);
fAngles[2] = floatstr(szAngle_Z);
entity_set_vector(ent, EV_VEC_angles, fAngles);
entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER);
entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1);
console_print(id, "Health circle has been created!");
}
else
{
console_print(id, "Failed to create the health circle!");
}
return 1;
}
public brain_work(id)
{
static width, Float:fAngles[3], Float:fRadius[3], Float:fOrigin[3], Float:fWidth[3];
pev(id, pev_angles, fAngles);
pev(id, pev_origin, fOrigin)
width = pev(id, pev_iuser4);
pev(id, pev_fuser4, fRadius[0]);
fRadius[1] = fRadius[0];
fRadius[2] = fRadius[0];
static g_aPlayers[32], Float:fPos[3], pnum, i, Float:z1, Float:x1, Float:c1;
get_players(g_aPlayers, pnum, "ach");
for(i = 0; i < pnum; i++)
{
pev(g_aPlayers[i], pev_origin, fPos);
fRadius[X] *= floatcos(fAngles[X], degrees);
fRadius[Y] *= floatsin(fAngles[Y], degrees);
fRadius[Z] *= floatcos(fAngles[Z], degrees);
fWidth[X] = float(width) * floatsin(fAngles[X], degrees);
fWidth[Y] = float(width) * floatcos(fAngles[Y], degrees);
fWidth[Z] = float(width) * floatsin(fAngles[Y], degrees);
if(
(z1=((fPos[X] - fOrigin[X]) ^ 2.0) + ((fPos[Z] - fOrigin[Z]) ^ 2.0)) - fWidth[X] <= floatpower(fRadius[X],2.0) + fWidth[X] &&
(x1=((fPos[X] - fOrigin[X]) ^ 2.0) + ((fPos[Y] - fOrigin[Y]) ^ 2.0)) - fWidth[Y] <= floatpower(fRadius[Y],2.0) + fWidth[Y] &&
(c1=((fPos[Y] - fOrigin[Y]) ^ 2.0) + ((fPos[Z] - fOrigin[Z]) ^ 2.0)) - fWidth[Z] <= floatpower(fRadius[X],2.0) + fWidth[Z])
{
client_print(0, print_chat, "------> player in circle <---------- ");
}
client_print(0, print_chat, "--------------------- ");
client_print(0, print_chat, "Z1: %.1f X1: %.1f C1: %.1f ", z1, x1, c1);
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS)
engfunc(EngFunc_WriteCoord, fOrigin[X] + fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[Y] + fRadius[Y])
engfunc(EngFunc_WriteCoord, fOrigin[Z] + fRadius[Z])
engfunc(EngFunc_WriteCoord, fOrigin[X] - fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[Y] - fRadius[Y])
engfunc(EngFunc_WriteCoord, fOrigin[Z] - fRadius[Z])
write_short(g_sprite)
write_byte(1)
write_byte(10)
write_byte(10)
write_byte(10)
write_byte(1)
write_byte(255)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(1)
message_end()
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS)
engfunc(EngFunc_WriteCoord, fOrigin[0] + fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[1] + fRadius[Z])
engfunc(EngFunc_WriteCoord, fOrigin[2] + fRadius[Y])
engfunc(EngFunc_WriteCoord, fOrigin[0] - fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[1] - fRadius[Z])
engfunc(EngFunc_WriteCoord, fOrigin[2] - fRadius[Y])
write_short(g_sprite)
write_byte(1)
write_byte(10)
write_byte(10)
write_byte(10)
write_byte(1)
write_byte(0)
write_byte(255)
write_byte(0)
write_byte(255)
write_byte(1)
message_end()
message_begin(MSG_ALL, SVC_TEMPENTITY)
write_byte(TE_BEAMPOINTS)
engfunc(EngFunc_WriteCoord, fOrigin[0] + fRadius[Y])
engfunc(EngFunc_WriteCoord, fOrigin[1] + fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[2] + fRadius[Z])
engfunc(EngFunc_WriteCoord, fOrigin[0] - fRadius[Y])
engfunc(EngFunc_WriteCoord, fOrigin[1] - fRadius[X])
engfunc(EngFunc_WriteCoord, fOrigin[2] - fRadius[Z])
write_short(g_sprite)
write_byte(1)
write_byte(10)
write_byte(10)
write_byte(10)
write_byte(1)
write_byte(0)
write_byte(0)
write_byte(255)
write_byte(255)
write_byte(1)
message_end()
client_print(0, print_chat, "Rad %.1f | %.1f | %.1f", fRadius[0], fRadius[1], fRadius[2]);
}
entity_set_float(id, EV_FL_nextthink, get_gametime() + 1.0);
}