Raised This Month: $ Target: $400
 0% 

Solved [ H3LP ] Find entity in half the sphere?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-23-2017 , 10:53   [ H3LP ] Find entity in half the sphere?
Reply With Quote #1

Hello, What I need is to find players in a sphere, but only those in front of the player, i.e. those who are behind or beside the player should not be identified.
__________________









Last edited by CrazY.; 07-28-2017 at 14:38.
CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-23-2017 , 11:31   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #2

Probably the easiest way: find_sphere_class/find_ent_in_sphere + is_in_viewcone.
__________________

Last edited by HamletEagle; 07-23-2017 at 11:31.
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-23-2017 , 19:11   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #3

Thanks!, but also I have another question, It looks like the find_ent_in_sphere first collects farther players to then check out the closest ones. Is there any way to set this up?
__________________








CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-23-2017 , 19:41   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #4

Quote:
Originally Posted by CrazY. View Post
Thanks!, but also I have another question, It looks like the find_ent_in_sphere first collects farther players to then check out the closest ones. Is there any way to set this up?
What are you wanting to "set up"?
__________________
fysiks is online now
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-23-2017 , 20:26   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #5

Sorry, what I meant in fact is to fix this to get closer players, that is, get closest players to then get the farthest.
__________________









Last edited by CrazY.; 07-23-2017 at 20:31.
CrazY. is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-23-2017 , 20:59   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #6

You can save the entities with their respective distances and then sort them. Or, if you are sure that it is always farthest to closest, then simply get all of them and reverse the order.
__________________
fysiks is online now
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-24-2017 , 09:48   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #7

Well, I'll see what I can do after all, I just need to detect only one player

Edit: I tried to enable 3d mode in Is_in_viewcone and tried to use the is_visible to not detect players that are eg behind the wall, but it does not work. Any suggestions?
__________________









Last edited by CrazY.; 07-24-2017 at 11:42.
CrazY. is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 07-24-2017 , 14:46   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #8

Traceline
Black Rose is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-27-2017 , 14:00   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #9

I tried to do the following:

Code:
public fw_Item_PostFrame(entity) {     if (!is_valid_ent(entity))         return HAM_IGNORED;     static id     id = get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)     if (!is_user_alive(id))         return HAM_IGNORED;     if (!GetPlayerBit(g_has_plasma_caster, id))         return HAM_IGNORED;     static Float:origin[3]     entity_get_vector(id, EV_VEC_origin, origin)     static victim     victim = -1     static traceline, Float:victim_origin[3], Float:vector[3], classname[32]     while ((victim = find_ent_in_sphere(victim, origin, 1000.0)))     {         if (!is_user_alive(victim))             continue;         if (avp_core_is_yautja(victim))             continue;         if (!is_in_viewcone(victim, origin))             continue;         entity_get_vector(victim, EV_VEC_origin, victim_origin)         traceline = trace_line(id, origin, victim_origin, vector)         if (!traceline)         {             message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)             write_byte(TE_SPRITE)             write_coord(floatround(victim_origin[0]))             write_coord(floatround(victim_origin[1]))             write_coord(floatround(victim_origin[2]))             write_short(sprite_aim)             write_byte(3)             write_byte(200)             message_end()         }         else         {             entity_get_string(entity, EV_SZ_classname, classname, charsmax(classname))             client_print(id, print_chat, "%s", classname)         }         break;     }           return HAM_IGNORED; }

However, trace_line is returning the index of the weapon I am using, in the case, the AWP. Any suggestions?
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-27-2017 , 14:17   Re: [ H3LP ] Find entity in half the sphere?
Reply With Quote #10

Loop throw all players better than using find ent in sphere...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 23:11.


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