Raised This Month: $ Target: $400
 0% 

Is user aiming at an entity


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-27-2008 , 16:23   Is user aiming at an entity
Reply With Quote #1

How do I find out if a player is aiming at an entity?

I have these two functions, but not sure if this would be an efficient way:
Code:
if(fm_get_user_aiming_ent(id, "func_breakable") == ent) {     // player is aiming at ent } // .... fm_get_user_aiming_ent(index, const sClassName[]) {     new Float:vOrigin[3];     fm_get_aim_origin(index, vOrigin);         new ent, sTempClass[32], iLen = sizeof(sTempClass) - 1;     do     {         pev(ent, pev_classname, sTempClass, iLen);         if(equali(sClassName, sTempClass) && fm_is_ent_visible(index, ent))         {             return ent;         }     }     while((ent = engfunc(EngFunc_FindEntityInSphere, index, vOrigin, 10.0)))         return 0; } // fakemeta_util.inc stock fm_get_aim_origin(index, Float:origin[3]) {     new Float:start[3], Float:view_ofs[3]     pev(index, pev_origin, start)     pev(index, pev_view_ofs, view_ofs)     xs_vec_add(start, view_ofs, start)     new Float:dest[3]     pev(index, pev_v_angle, dest)     engfunc(EngFunc_MakeVectors, dest)     global_get(glb_v_forward, dest)     xs_vec_mul_scalar(dest, 9999.0, dest)     xs_vec_add(start, dest, dest)     engfunc(EngFunc_TraceLine, start, dest, 0, index, 0)     get_tr2(0, TR_vecEndPos, origin)     return 1 } // fakemeta_util.inc stock bool:fm_is_ent_visible(index, entity, ignoremonsters = 0) {     new Float:start[3], Float:dest[3]     pev(index, pev_origin, start)     pev(index, pev_view_ofs, dest)     xs_vec_add(start, dest, start)     pev(entity, pev_origin, dest)     engfunc(EngFunc_TraceLine, start, dest, ignoremonsters, index, 0)     new Float:fraction     get_tr2(0, TR_flFraction, fraction)     if (fraction == 1.0 || get_tr2(0, TR_pHit) == entity)         return true     return false }

1. I'm not sure if this would work properly
2. I'm not sure if this is the best way to do this
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
 



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 13:00.


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