Raised This Month: $ Target: $400
 0% 

get_user_aiming


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-12-2010 , 12:00   get_user_aiming
Reply With Quote #1

I'm trying to dip into get_player_aim to tell if one player is looking at another within a short distance, but not real short.

Any examples?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 07-12-2010 at 12:02.
GXLZPGX is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-12-2010 , 12:01   Re: get_player_aim
Reply With Quote #2

get_player_aim doesn't exist.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 07-12-2010 , 12:02   Re: get_player_aim
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
get_player_aim doesn't exist.
get_user_aiming, my apologies. Changed title.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-12-2010 , 12:10   Re: get_user_aiming
Reply With Quote #4

get_user_aiming() returns the len between the first param and the second.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 07-12-2010 , 12:25   Re: get_user_aiming
Reply With Quote #5

PHP Code:
static cell AMX_NATIVE_CALL get_user_aiming(AMX *amxcell *params)
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid player id %d"index);
        return 
0;
    }
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);
    
cell *cpId get_amxaddr(amxparams[2]);
    
cell *cpBody get_amxaddr(amxparams[3]);
    
    
REAL pfloat 0.0f;

    if (
pPlayer->ingame)
    {
        
edict_tedict pPlayer->pEdict;
        
        
Vector v_forward;
        
Vector v_src edict->v.origin edict->v.view_ofs;

        
ANGLEVECTORS(edict->v.v_anglev_forwardNULLNULL);
        
TraceResult trEnd;
        
Vector v_dest v_src v_forward static_cast<float>(params[4]);
        
TRACE_LINE(v_srcv_dest0edict, &trEnd);
        
        *
cpId FNullEnt(trEnd.pHit) ? ENTINDEX(trEnd.pHit);
        *
cpBody trEnd.iHitgroup;
        
        if (
trEnd.flFraction 1.0)
        {
            
pfloat = (trEnd.vecEndPos v_src).Length();
        }
    } 
    else 
    {
        *
cpId 0;
        *
cpBody 0;
    }
    
    return 
amx_ftoc(pfloat);

A convertion to amxx by me

PHP Code:
Float:eng_get_user_aiming(id, &target, &bodyFloat:dist 9999.0)
{
    if(
id || id get_maxplayers())
    {
        
log_error(AMX_ERR_NATIVE"Invalid player id %d"id);
        return 
0;
    }
    
    new 
flFloat 0.0
    
    
if(is_user_connected(id))
    {
        new 
Float:flVecSrc[3], Float:flViewOfs[3]
        
entity_get_vector(idEV_VEC_originflVecSrc)
        
entity_get_vector(idEV_VEC_view_ofsflViewOfs)
        
        
flVecSrc[0] += flViewOfs[0]
        
flVecSrc[1] += flViewOfs[1]
        
flVecSrc[2] += flViewOfs[2]
        
        new 
Float:flAngles[3], Float:flForward[3]
        
entity_get_vector(idEV_VEC_v_angleflAngles)
        
angle_vector(flAnglesANGLEVECTOR_FORWARDflForward)
        
        new 
Float:flVecDest[3]
        
        
flVecDest[0] = flVecSrc[0] + (flForward[0] * dist)
        
flVecDest[1] = flVecSrc[1] + (flForward[1] * dist)
        
flVecDest[2] = flVecSrc[2] + (flForward[2] * dist)
        
        new 
Float:flVecEnd[3]
        
        
trace_line(idflVecSrcflVecDestflVecEnd)
        
        
id traceresult(TR_Hit) ? traceresult(TR_Hit)
        
body traceresult(TR_Hitgroup)
        
        new 
Float:flFraction
        traceresult
(TR_FractionflFraction)
        
        if(
flFraction 1.0)
            
flFloat get_distance_f(flVecSrcflVecEnd)
    }
    else
    {
        
target 0
        body 
0
    
}
    
    return 
flFloat

__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by meTaLiCroSS; 07-12-2010 at 12:41.
meTaLiCroSS is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-12-2010 , 16:28   Re: get_user_aiming
Reply With Quote #6

Why don't use amxx's native? http://www.amxmodx.org/funcwiki.php?...ming&go=search
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
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 07:05.


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