Rules FAQ Members List Search Register Login

 Raised This Month: \$68 Target: \$400 17%

Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
 09-23-2019 , 00:50   How to create circle #1 Is it possible to create a circle and detect whether the player pass through it if yes then how? __________________ @Jailbreak MOD [Alot of features + API] 100% done ! @User Tag Prefix 100% done ! @Mystery Box 100% done ! @VIP System 100% done !
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
 09-23-2019 , 03:08   Re: How to create circle #2 Yes, check my CSBR mod. You'd have to compare the 2D length of the circle's radius against player. __________________ Last edited by edon1337; 09-23-2019 at 03:11.
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
 09-23-2019 , 13:44   Re: How to create circle #3 i was trying to achieve this way using an entity touch but seems entity hitboxes are not supportive of a circle :'( __________________ @Jailbreak MOD [Alot of features + API] 100% done ! @User Tag Prefix 100% done ! @Mystery Box 100% done ! @VIP System 100% done !
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
09-23-2019 , 14:26   Re: How to create circle
#4

Quote:
 Originally Posted by edon1337 Yes, check my CSBR mod. You'd have to compare the 2D length of the circle's radius against player.
my problem is quite harder because the circle i want to create in multiple angles.
__________________
@Jailbreak MOD [Alot of features + API] 100% done !
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Last edited by Natsheh; 09-24-2019 at 01:15.
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
09-23-2019 , 23:13   Re: How to create circle
#5

Quote:
 Originally Posted by Natsheh my problem is quite harder because the circle i want to create has multiple angles.
Circles have angles?
__________________
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
 09-24-2019 , 01:10   Re: How to create circle #6 Lmao I didn't think this through typing it, I mean I want create a circle in multiple directions and check if the player is in it lets say it's more like player inside cylinder I want to give width to that circle/cylinder I'm using this equation to detect how far the player from the circle in different axis (PlayerOriginX - circleCenterX )^2 + floatsqroot((PlayerOriginY - circleCenterY)^2)) < Radius I'll post what I have tried after I come back from work. __________________ @Jailbreak MOD [Alot of features + API] 100% done ! @User Tag Prefix 100% done ! @Mystery Box 100% done ! @VIP System 100% done ! Last edited by Natsheh; 09-24-2019 at 01:14.
Smilex_Gamer
Member
Join Date: Apr 2017
Location: Portugal
09-24-2019 , 11:06   Re: How to create circle
#7

Quote:
 Originally Posted by Natsheh Lmao I didn't think this through typing it, I mean I want create a circle in multiple directions and check if the player is in it lets say it's more like player inside cylinder I want to give width to that circle/cylinder I'm using this equation to detect how far the player from the circle in different axis (PlayerOriginX - circleCenterX )^2 + floatsqroot((PlayerOriginY - circleCenterY)^2)) < Radius I'll post what I have tried after I come back from work.
First: A circle is 2D. A cylinder is 3D.
Maybe you're trying to know if a player is inside a sphere.
If that's so, the formula to know if something is inside that sphere is this one: (x - SphereCenterX)^2 + (y - SphereCenterY)^2 + (z - SphereCenterZ)^2 < Radius^2
If it's a circle, then it's: (x - CircleCenterX)^2 + (y - CircleCenterY)^2 < Radius^2

P.S: The only thing you got wrong in your formula was the radius that wasn't square rooted.
P.S.S: Of course, because Goldsource is a 3D game engine, your circle you create has a Z origin, so you should use the first formula in my comment.

Last edited by Smilex_Gamer; 09-24-2019 at 11:23.
Natsheh
Veteran Member
Join Date: Sep 2012
Location: Muslim and proud!
 09-24-2019 , 12:48   Re: How to create circle #8 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 #include #include #include #define PLUGIN "Health circle"#define VERSION "1.0"#define AUTHOR "Natsheh"new g_sprite;#define X 0#define Y 1#define Z 2public 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, "    ");    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 Float:fAngles[3], Float:fRadius[3], Float:fOrigin[3], Float:fWidth;    pev(id, pev_angles, fAngles);    pev(id, pev_origin, fOrigin)    fWidth = float(pev(id, pev_iuser4));    pev(id, pev_fuser4, fRadius[X]);    fRadius[Y] = 0.0;    fRadius[Z] = 0.0;        static g_aPlayers[32], Float:fPos[3], pnum, i, Float:z1, Float:x1, Float:c1; c1 = fRadius[X];    get_players(g_aPlayers, pnum, "ach");    for(i = 0; i < pnum; i++)    {        pev(g_aPlayers[i], pev_origin, fPos);                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(fPos, fRadius);                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(fPos, fRadius);                /*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(0, print_chat, "--------------------- ");        client_print(0, print_chat, "Z1: %.1f X1: %.1f C1: %.1f ", floatsqroot(z1), floatsqroot(x1), floatsqroot(c1));                const iDivides = 32        static Float:AngleMulScalar; AngleMulScalar = (360.0 / iDivides);        static Float:fTemp[3], Float:fAngle[3], i,        Float:fVector1[3] = { 0.0, 0.0, 0.0 }, Float:fVector2[3] = { 0.0, 0.0, 0.0 }, Float:fStart1[3], Float:fStart2[3];                xs_vec_set(fAngle, 0.0, 0.0, 0.0);        xs_vec_normalize(fRadius, fAngle);        vector_to_angle(fAngle, fAngle);        for(i = 0; i <= iDivides; i++)        {            if(i > 0)            {                xs_vec_copy(fVector1, fStart1);                xs_vec_copy(fVector2, fStart2);            }                        angle_vector(fAngle, ANGLEVECTOR_RIGHT, fTemp);            xs_vec_mul_scalar(fTemp, floatabs(c1), fVector1);            xs_vec_mul_scalar(fTemp, -floatabs(c1), fVector2);                        xs_vec_add(fOrigin, fVector1, fVector1);            xs_vec_add(fOrigin, fVector2, fVector2);                        xs_vec_mul_scalar(fTemp, AngleMulScalar, fTemp);            vector_to_angle(fTemp, fTemp);            fAngle[X] += fTemp[X];            fAngle[Y] += fTemp[Y];            fAngle[Z] += fTemp[Z];            if(i > 0)            {                createline(fStart1, fVector1)                createline(fStart2, fVector2)            }        }                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);}  ``` __________________ @Jailbreak MOD [Alot of features + API] 100% done ! @User Tag Prefix 100% done ! @Mystery Box 100% done ! @VIP System 100% done ! Last edited by Natsheh; 09-28-2019 at 12:36.
Smilex_Gamer
Member
Join Date: Apr 2017
Location: Portugal
09-24-2019 , 13:43   Re: How to create circle
#9

Quote:
 Originally Posted by Natsheh 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  #include  #include  #include  #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, "    ");     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); }  ```
Humm.. what does that do? I tried to understand it but stopped in the middle of brain_work(id).
E1_531G
Senior Member
Join Date: Dec 2017
 09-24-2019 , 13:50   Re: How to create circle #10 You call it "health circe" but you are doing sphere math, so these should help: https://www.amxmodx.org/api/engine/find_ent_in_sphere https://www.amxmodx.org/api/engine/find_sphere_class __________________ My English is A0

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TF2Items         TFDodgeball         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 12:31.

 DMCA - Archive - Top