AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Find entity in half the sphere? (https://forums.alliedmods.net/showthread.php?t=299698)

CrazY. 07-23-2017 10:53

[ H3LP ] Find entity in half the sphere?
 
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.

HamletEagle 07-23-2017 11:31

Re: [ H3LP ] Find entity in half the sphere?
 
Probably the easiest way: find_sphere_class/find_ent_in_sphere + is_in_viewcone.

CrazY. 07-23-2017 19:11

Re: [ H3LP ] Find entity in half the sphere?
 
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?

fysiks 07-23-2017 19:41

Re: [ H3LP ] Find entity in half the sphere?
 
Quote:

Originally Posted by CrazY. (Post 2537260)
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"?

CrazY. 07-23-2017 20:26

Re: [ H3LP ] Find entity in half the sphere?
 
Sorry, what I meant in fact is to fix this to get closer players, that is, get closest players to then get the farthest.

fysiks 07-23-2017 20:59

Re: [ H3LP ] Find entity in half the sphere?
 
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.

CrazY. 07-24-2017 09:48

Re: [ H3LP ] Find entity in half the sphere?
 
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?

Black Rose 07-24-2017 14:46

Re: [ H3LP ] Find entity in half the sphere?
 
Traceline

CrazY. 07-27-2017 14:00

Re: [ H3LP ] Find entity in half the sphere?
 
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?

Natsheh 07-27-2017 14:17

Re: [ H3LP ] Find entity in half the sphere?
 
Loop throw all players better than using find ent in sphere...


All times are GMT -4. The time now is 23:11.

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