AlliedModders

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

XSlayer 07-28-2022 17:03

This or This
 
Hi, in terms of memory, whis is better to use?

This
PHP Code:

velocity_by_aim(iIndexiVelocityFloat:vRetValue[3]); 

>

PHP Code:

static cell AMX_NATIVE_CALL VelocityByAim(AMX *amxcell *params)
{
    
int iEnt params[1];
    
int iVelocity params[2];
    
cell *vRet get_amxaddr(amxparams[3]);
    
Vector vVector Vector(000);
    
edict_t *pEnt NULL;
 
    if (
iEnt || iEnt gpGlobals->maxEntities)
    {
        
LogError(amxAMX_ERR_NATIVE"Entity out of range (%d)"iEnt);
        return 
0;
    }
    else
    {
        if (
iEnt && iEnt <= gpGlobals->maxClients)
        {
            if (!
GET_PLAYER_POINTER_I(iEnt)->ingame)
            {
                
LogError(amxAMX_ERR_NATIVE"Invalid player %d (not ingame)"iEnt);
                return 
0;
            }
            
pEnt GET_PLAYER_POINTER_I(iEnt)->pEdict;
        } else {
            
pEnt INDEXENT(iEnt);
        }
    }
 
    if (!
pEnt)
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid entity %d (nullent)"iEnt);
        return 
0;
    }
 
    
MAKE_VECTORS(pEnt->v.v_angle);
    
vVector gpGlobals->v_forward iVelocity;
 
    
vRet[0] = FloatToCell(vVector.x);
    
vRet[1] = FloatToCell(vVector.y);
    
vRet[2] = FloatToCell(vVector.z);
 
    return 
1;


Or This:

PHP Code:

stock setAIMVelocityClientFloat:__fl_SpeedFloat:__fl_Velocity[3] )
{
    static 
Float:__fl_v_Angles[3];
    
entity_get_vectorClientEV_VEC_v_angle__fl_v_Angles );

    
engfuncEngFunc_MakeVectors__fl_v_Angles );
    
get_global_vector(GL_v_forward__fl_v_Angles);

    
__fl_Velocity[0] = __fl_v_Angles[0] * __fl_Speed;
    
__fl_Velocity[1] = __fl_v_Angles[1] * __fl_Speed;
    
__fl_Velocity[2] = __fl_v_Angles[2] * __fl_Speed;



Bugsy 07-28-2022 18:06

Re: This or This
 
I always use the native version, unless I need to modify the functionality in any way.


All times are GMT -4. The time now is 15:38.

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