AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   I want to get velocity by viewangle (https://forums.alliedmods.net/showthread.php?t=82322)

hzqst 12-21-2008 07:48

I want to get velocity by viewangle
 
but doesn't work
Quote:

if(buttons & IN_MOVELEFT){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, 0.0, -600.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}
if(buttons & IN_MOVERIGHT){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, 0.0, 600.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}
if(buttons & IN_FORWARD){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, 600.0, 0.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}
if(buttons & IN_BACK){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, -600.0, 0.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}
Quote:

stock ckrun_VecAdd(Float:vec1[3], Float:vec2[3]){
vec1[0] += vec2[0]
vec1[1] += vec2[1]
vec1[2] += vec2[2]
return 1
}

LagParty 12-21-2008 15:04

Re: I want to get velocity by viewangle
 
as seen in holoduke plugin by vet:
PHP Code:

new Float:Vel1[3], Float:Vel2[3]
velocity_by_aim(id,module,Vel1//module is how fast you want it to be
pev(id,pev_velocity,Vel2)
Vel2[0] += Vel1[0]
Vel2[1] += Vel1[1]
Vel2[2] += Vel1[2]
set_pev(id,pev_velocity,Vel2

does that help?

hzqst 12-22-2008 05:53

Re: I want to get velocity by viewangle
 
i meant move left or right not forward

hzqst 12-22-2008 10:42

Re: I want to get velocity by viewangle
 
-_-if i need the code that makes the player move left or right?with pev_velocity

Dores 12-22-2008 11:31

Re: I want to get velocity by viewangle
 
The velocity_by_aim native calculates the player's velocity according to the determined speed and the player's view angles. So I used the player's maxspeed to determine his velocity while walking.

As you asked:
Quote:

Originally Posted by hzqst
I want to get velocity by viewangle

That's what velocity_by_aim does.

cs1.7 12-31-2008 05:33

Re: I want to get velocity by viewangle
 
wow awesome. did you solve the problem? i was trying to do that too. Can anyone tell how it's beeing done?

+karma

Exolent[jNr] 12-31-2008 17:41

Re: I want to get velocity by viewangle
 
http://forums.alliedmods.net/showpos...60&postcount=5

cs1.7 01-01-2009 00:30

Re: I want to get velocity by viewangle
 
How do you use velocity_by_aim to move left (IN_MOVELEFT), right (IN_MOVERIGHT), back (IN_BACK) etc.?

I've been trying that for a some time: Question about noclip #5


could you post an example how to use velocity_by_aim for IN_MOVELEFT ?


Code:

if(buttons & IN_MOVELEFT){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, 0.0, -600.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}


Dores 01-01-2009 08:03

Re: I want to get velocity by viewangle
 
Quote:

Originally Posted by cs1.7 (Post 736368)
How do you use velocity_by_aim to move left (IN_MOVELEFT), right (IN_MOVERIGHT), back (IN_BACK) etc.?

I've been trying that for a some time: Question about noclip #5


could you post an example how to use velocity_by_aim for IN_MOVELEFT ?


Code:

if(buttons & IN_MOVELEFT){
pev(id, pev_v_angle, vangle)
engfunc(EngFunc_AngleVectors, vangle, 0.0, -600.0, 0.0)
ckrun_VecAdd(velocity, vangle)
}


Code:
#include <amxmodx> #include <fakemeta> #define VERSION "1.0" public plugin_init() {     register_plugin( "Right Left Forward Backward Velocity", VERSION, "Dores" );         register_forward( FM_PlayerPreThink, "Forward_PreThink" ); } public Forward_PreThink( id ) {     if( !is_user_alive( id ) )         return FMRES_IGNORED;         new Float:vAngles[ 3 ], Float:flRight[ 3 ], Float:flForward[ 3 ];     pev( id, pev_v_angle, vAngles );     angle_vector( vAngles, ANGLEVECTOR_RIGHT, flRight );     angle_vector( vAngles, ANGLEVECTOR_FORWARD, flForward );         new Float:maxspeed, Float:flVeloc[ 3 ];     pev( id, pev_maxspeed, maxspeed );     velocity_by_aim( id, floatround( maxspeed ), flVeloc );         static Buttons ; pev( id, pev_button, Buttons );         if( Buttons & IN_FORWARD )     {                 flForward[ 0 ] *= flVeloc[ 0 ];         flForward[ 1 ] *= flVeloc[ 1 ];         flForward[ 2 ] *= flVeloc[ 2 ];         set_pev( id, pev_velocity, flForward );     }         if( Buttons & IN_RIGHT )     {         flRight[ 0 ] *= flVeloc[ 0 ];         flRight[ 1 ] *= flVeloc[ 1 ];         flRight[ 2 ] *= flVeloc[ 2 ];         set_pev( id, pev_velocity, flRight );     }         if( Buttons & IN_LEFT )     {         new Float:flLeft[ 3 ];         flLeft[ 0 ] = -flRight[ 0 ] * flVeloc[ 0 ];         flLeft[ 1 ] = -flRight[ 1 ] * flVeloc[ 1 ];         flLeft[ 2 ] = -flRight[ 2 ] * flVeloc[ 2 ];         set_pev( id, pev_velocity, flLeft );     }         if( Buttons & IN_BACK )     {         new Float:flBack[ 3 ];         flBack[ 0 ] = -flForward[ 0 ] * flVeloc[ 0 ];         flBack[ 1 ] = -flForward[ 1 ] * flVeloc[ 1 ];         flBack[ 2 ] = -flForward[ 2 ] * flVeloc[ 2 ];         set_pev( id, pev_velocity, flBack );     }         return FMRES_IGNORED; }

cs1.7 01-01-2009 12:57

Re: I want to get velocity by viewangle
 
i could not figure out how to make it work. what do i have to edit in the code?


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

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