Raised This Month: $ Target: $400
 0% 

How to create circle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 09-24-2019 , 12:48   Re: How to create circle
Reply With Quote #1

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 
Float:fAngles[3], Float:fRadius[3], Float:fOrigin[3], Float:fWidth;
    
pev(idpev_anglesfAngles);
    
pev(idpev_originfOrigin)
    
fWidth float(pev(idpev_iuser4));
    
pev(idpev_fuser4fRadius[X]);
    
fRadius[Y] = 0.0;
    
fRadius[Z] = 0.0;
    
    static 
g_aPlayers[32], Float:fPos[3], pnumiFloat:z1Float:x1Float:c1c1 fRadius[X];
    
get_players(g_aPlayerspnum"ach");
    for(
0pnumi++)
    {
        
pev(g_aPlayers[i], pev_originfPos);
        
        
fPos[X] = fRadius[X] * floatcos(fAngles[Y],degrees) - floatsin(fAngles[Y],degrees) * fRadius[Y];
        
fPos[Y] = fRadius[X] * floatsin(fAngles[Y],degrees) + floatcos(fAngles[Y],degrees) * fRadius[Y];
        
fPos[Z] = 0.0
        xs_vec_copy
(fPosfRadius);
        
        
fPos[X] = fRadius[X] * floatcos(fAngles[X],degrees) + fRadius[Y] * floatsin(fAngles[X],degrees);
        
fPos[Y] = fRadius[Y];
        
fPos[Z] = -fRadius[X] * floatsin(fAngles[X],degrees) + fRadius[Z] * floatcos(fAngles[X],degrees);
        
xs_vec_copy(fPosfRadius);
        
        
/*x1=floatsqroot(floatpower((fPos[X] - fOrigin[X]),2.0) + floatpower((fPos[Y] - fOrigin[Y]),2.0));
        z1=floatsqroot(floatpower((fPos[X] - fOrigin[X]),2.0) + floatpower((fPos[Z] - fOrigin[Z]),2.0));
        c1=floatsqroot(floatpower((fPos[Y] - fOrigin[Y]),2.0) + floatpower((fPos[Z] - fOrigin[Z]),2.0));
        if(x1 < fRadius[X] && floatabs(fPos[Z] - fOrigin[Z]) <= fRadius[X] ||
        z1 < fRadius[Y] && floatabs(fPos[Y] - fOrigin[Y]) <= fRadius[Y] ||
        c1 < fRadius[X] && floatabs(fPos[X] - fOrigin[X]) <= fRadius[Z] )
        { 
            client_print(0, print_chat, "------> player in circle <---------- ");
        }*/
        
        
client_print(0print_chat"--------------------- ");
        
client_print(0print_chat"Z1: %.1f X1: %.1f C1: %.1f "floatsqroot(z1), floatsqroot(x1), floatsqroot(c1));
        
        const 
iDivides 32
        
static Float:AngleMulScalarAngleMulScalar = (360.0 iDivides);
        static 
Float:fTemp[3], Float:fAngle[3], i,
        
Float:fVector1[3] = { 0.00.00.0 }, Float:fVector2[3] = { 0.00.00.0 }, Float:fStart1[3], Float:fStart2[3];
        
        
xs_vec_set(fAngle0.00.00.0);
        
xs_vec_normalize(fRadiusfAngle);
        
vector_to_angle(fAnglefAngle);
        for(
0<= iDividesi++)
        {
            if(
0)
            {
                
xs_vec_copy(fVector1fStart1);
                
xs_vec_copy(fVector2fStart2);
            }
            
            
angle_vector(fAngleANGLEVECTOR_RIGHTfTemp);
            
xs_vec_mul_scalar(fTempfloatabs(c1), fVector1);
            
xs_vec_mul_scalar(fTemp, -floatabs(c1), fVector2);
            
            
xs_vec_add(fOriginfVector1fVector1);
            
xs_vec_add(fOriginfVector2fVector2);
            
            
xs_vec_mul_scalar(fTempAngleMulScalarfTemp);
            
vector_to_angle(fTempfTemp);
            
fAngle[X] += fTemp[X];
            
fAngle[Y] += fTemp[Y];
            
fAngle[Z] += fTemp[Z];
            if(
0)
            {
                
createline(fStart1fVector1)
                
createline(fStart2fVector2)
            }
        }
        
        
client_print(0print_chat"Rad %.1f | %.1f | %.1f"fRadius[0], fRadius[1], fRadius[2]);
    }
    
    
entity_set_float(idEV_FL_nextthinkget_gametime() + 1.0);

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 09-28-2019 at 12:36.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Smilex_Gamer
Senior Member
Join Date: Apr 2017
Location: Portugal
Old 09-24-2019 , 13:43   Re: How to create circle
Reply With Quote #2

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