PDA

View Full Version : HELP PLEASE !!! <- CHANGE ME QUICK


He@dShot
04-18-2008, 13:30
Hi ! Ok, here's the problems:
1. how can I find out if a player has any other player in vew ?
2. how can I get the distance between a player(entity) and a weapon entity ?
Thanks in advance !

Styles
04-18-2008, 13:35
You can use fm_is_in_viewcone

errm for number two you could do like

#define fm_get_entity_distance(%1,%2) floatround(fm_entity_range(%1, %2)) // Your best bet...

// View Cone
stock bool:fm_is_in_viewcone(index, const Float:point[3]) {
new Float:angles[3]
pev(index, pev_angles, angles)
engfunc(EngFunc_MakeVectors, angles)
global_get(glb_v_forward, angles)
angles[2] = 0.0

new Float:origin[3], Float:diff[3], Float:norm[3]
pev(index, pev_origin, origin)
xs_vec_sub(point, origin, diff)
diff[2] = 0.0
xs_vec_normalize(diff, norm)

new Float:dot, Float:fov
dot = xs_vec_dot(norm, angles)
pev(index, pev_fov, fov)
if (dot >= floatcos(fov * M_PI / 360))
return true

return false
}


Do you could do a loop for every player and see if they are in the view cone.
I have the in view somewhere. Ill look around for it.