Raised This Month: $ Target: $400
 0% 

How to create circle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Smilex_Gamer
Senior Member
Join Date: Apr 2017
Location: Portugal
Old 09-24-2019 , 13:43   Re: How to create circle
Reply With Quote #1

Quote:
Originally Posted by Natsheh View Post
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(PLUGINVERSIONAUTHOR)
    
    
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(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) return 1;
    
    new 
ent = -1target_circle 0Float:wanted_distance 250.0Float:fOrigin[3], Float:fOrigin2[3], Float:z;
    
pev(idpev_originfOrigin);
    while( (
ent find_ent_by_class(ent"health_circle")) > )
    {
        
pev(entpev_originfOrigin2);
        if( (
z=get_distance_f(fOriginfOrigin2)) <= wanted_distance )
        {
            
target_circle entwanted_distance z;
        }
    }
    
    if(
target_circle 0)
    {
        
set_entity_flags(target_circleFL_KILLMEtrue);
        
console_print(id"The health circle nearby was removed!");
    }
    else
    {
        
console_print(id"No health circles were found!");
    }
    return 
1;
}

public 
handler_command(idlevelcid)
{
    if(!
cmd_access(idlevelcid2)) return 1;
    
    new 
szRadius[5], szWidth[5], szAngle_X[5], szAngle_Y[5], szAngle_Z[5];
    
read_argv(1szRadiuscharsmax(szRadius));
    
read_argv(2szWidthcharsmax(szWidth));
    
read_argv(3szAngle_Xcharsmax(szAngle_X));
    
read_argv(4szAngle_Ycharsmax(szAngle_Y));
    
read_argv(5szAngle_Zcharsmax(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(entEV_SZ_classname"health_circle");
        
        new 
Float:fAngles[3];
        
        
entity_get_vector(idEV_VEC_originfAngles);
        
entity_set_origin(entfAngles);
        
        
entity_set_int(entEV_INT_iuser4str_to_num(szWidth));
        
entity_set_float(entEV_FL_fuser4floatstr(szRadius));
        
        
fAngles[0] = floatstr(szAngle_X);
        
fAngles[1] = floatstr(szAngle_Y);
        
fAngles[2] = floatstr(szAngle_Z);
        
entity_set_vector(entEV_VEC_anglesfAngles);
        
        
entity_set_int(entEV_INT_solidSOLID_TRIGGER);
        
entity_set_float(entEV_FL_nextthinkget_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 
widthFloat:fAngles[3], Float:fRadius[3], Float:fOrigin[3], Float:fWidth[3];
    
pev(idpev_anglesfAngles);
    
pev(idpev_originfOrigin)
    
width pev(idpev_iuser4);
    
pev(idpev_fuser4fRadius[0]);
    
fRadius[1] = fRadius[0];
    
fRadius[2] = fRadius[0];

    static 
g_aPlayers[32], Float:fPos[3], pnumiFloat:z1Float:x1Float:c1;
    
get_players(g_aPlayerspnum"ach");
    for(
0pnumi++)
    {
        
pev(g_aPlayers[i], pev_originfPos);

        
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(0print_chat"------> player in circle <---------- ");
        }
        
        
client_print(0print_chat"--------------------- ");
        
client_print(0print_chat"Z1: %.1f X1: %.1f C1: %.1f "z1x1c1);
        
        
        
message_begin(MSG_ALLSVC_TEMPENTITY)
        
write_byte(TE_BEAMPOINTS)
        
engfunc(EngFunc_WriteCoordfOrigin[X] + fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[Y] + fRadius[Y])
        
engfunc(EngFunc_WriteCoordfOrigin[Z] + fRadius[Z])
        
engfunc(EngFunc_WriteCoordfOrigin[X] - fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[Y] - fRadius[Y])
        
engfunc(EngFunc_WriteCoordfOrigin[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_ALLSVC_TEMPENTITY)
        
write_byte(TE_BEAMPOINTS)
        
engfunc(EngFunc_WriteCoordfOrigin[0] + fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[1] + fRadius[Z])
        
engfunc(EngFunc_WriteCoordfOrigin[2] + fRadius[Y])
        
engfunc(EngFunc_WriteCoordfOrigin[0] - fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[1] - fRadius[Z])
        
engfunc(EngFunc_WriteCoordfOrigin[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_ALLSVC_TEMPENTITY)
        
write_byte(TE_BEAMPOINTS)
        
engfunc(EngFunc_WriteCoordfOrigin[0] + fRadius[Y])
        
engfunc(EngFunc_WriteCoordfOrigin[1] + fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[2] + fRadius[Z])
        
engfunc(EngFunc_WriteCoordfOrigin[0] - fRadius[Y])
        
engfunc(EngFunc_WriteCoordfOrigin[1] - fRadius[X])
        
engfunc(EngFunc_WriteCoordfOrigin[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(0print_chat"Rad %.1f | %.1f | %.1f"fRadius[0], fRadius[1], fRadius[2]);
    }
    
    
entity_set_float(idEV_FL_nextthinkget_gametime() + 1.0);

Humm.. what does that do? I tried to understand it but stopped in the middle of brain_work(id).
Smilex_Gamer is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode