Hi, in terms of memory, whis is better to use?
This
PHP Code:
velocity_by_aim(iIndex, iVelocity, Float:vRetValue[3]);
>
PHP Code:
static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
{
int iEnt = params[1];
int iVelocity = params[2];
cell *vRet = get_amxaddr(amx, params[3]);
Vector vVector = Vector(0, 0, 0);
edict_t *pEnt = NULL;
if (iEnt < 0 || iEnt > gpGlobals->maxEntities)
{
LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", iEnt);
return 0;
}
else
{
if (iEnt > 0 && iEnt <= gpGlobals->maxClients)
{
if (!GET_PLAYER_POINTER_I(iEnt)->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player %d (not ingame)", iEnt);
return 0;
}
pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict;
} else {
pEnt = INDEXENT(iEnt);
}
}
if (!pEnt)
{
LogError(amx, AMX_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 setAIMVelocity( Client, Float:__fl_Speed, Float:__fl_Velocity[3] )
{
static Float:__fl_v_Angles[3];
entity_get_vector( Client, EV_VEC_v_angle, __fl_v_Angles );
engfunc( EngFunc_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;
}