AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_aiming (https://forums.alliedmods.net/showthread.php?t=132152)

GXLZPGX 07-12-2010 12:00

get_user_aiming
 
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?

ConnorMcLeod 07-12-2010 12:01

Re: get_player_aim
 
get_player_aim doesn't exist.

GXLZPGX 07-12-2010 12:02

Re: get_player_aim
 
Quote:

Originally Posted by ConnorMcLeod (Post 1236731)
get_player_aim doesn't exist.

get_user_aiming, my apologies. Changed title.

wrecked_ 07-12-2010 12:10

Re: get_user_aiming
 
get_user_aiming() returns the len between the first param and the second.

meTaLiCroSS 07-12-2010 12:25

Re: get_user_aiming
 
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 :crab::crab::crab:

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



Alka 07-12-2010 16:28

Re: get_user_aiming
 
Why don't use amxx's native? http://www.amxmodx.org/funcwiki.php?...ming&go=search


All times are GMT -4. The time now is 07:05.

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