AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Find origin of a players head. (https://forums.alliedmods.net/showthread.php?t=84922)

Bugsy 02-02-2009 23:09

[SOLVED] Find origin of a players head.
 
Sorry http://forums.alliedmods.net/showthread.php?t=79054

I want to be able to check if a players head is visible for another player. How would I edit this to return true if origin2s head is visible to origin1? +karma

PHP Code:

public is_in_line_of_sight(origin1[3], origin2[3], ignore_players)
{
    new 
Float:fOrigin1[3];
    new 
Float:fOrigin2[3];
    new 
trace 0
    IVecFVec
(origin1,fOrigin1 );
    
IVecFVec(origin2,fOrigin2 );
    
    
draw_laserfOrigin1 fOrigin2 )
    
    
engfunc(EngFunc_TraceLinefOrigin1fOrigin2, (ignore_players IGNORE_MONSTERS DONT_IGNORE_MONSTERS), 0trace)
    
    new 
Float:fraction
    get_tr2
(traceTR_flFractionfraction)
    
    return (
fraction == 1.0) ? 0



Exolent[jNr] 02-03-2009 14:28

Re: [SOLVED] Find origin of a players head.
 
Code:
bool:user_can_see_head(client, victim) {     if( !is_user_alive(client) || !is_user_alive(victim) ) return false;         static Float:client_head[3];     static Float:victim_head[3];     static Float:angles[3];         engfunc(EngFunc_GetBonePosition, client, 8, client_head, angles);     engfunc(EngFunc_GetBonePosition, victim, 8, victim_head, angles);         engfunc(EngFunc_TraceLine, client_head, victim_head, DONT_IGNORE_MONSTERS, client, 0);         return (get_tr2(0, TR_pHit) == victim); }


All times are GMT -4. The time now is 01:41.

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