AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Looking for a function thatll set the players current velocity.. NOT MAXSPEED (https://forums.alliedmods.net/showthread.php?t=332308)

12Toastie 05-05-2021 01:52

Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
Allow me to explain.. this is for TFC..

In TFC each class has their own maxspeed, and are allowed to bunnyhop up to 170% of their maxspeed. If they try to bhop over that 170%, itll reset their velocity to their maxspeed.

For example, a Scout has a maxspeed of 400.. and can go as high as 680 and if he tries to bhop while being over 680, his velocity will be reset to 400.

Now there is another thing called a "chop hop"... where a player can actually maintain a high rate of speed past 680 by +duck'ing instead. I want to apply that same mechanic to +duck where if they try it while over 680, itll set them back to 400. Is there a function thatll set their current velocity given these conditions?

HamletEagle 05-05-2021 03:02

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
pev_velocity?

12Toastie 05-05-2021 11:25

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
Hey thank you for your reply! Ya i have been trying to use that. I am a rather novice programmer so I am not sure if there is something I need to do differently, but I am getting an effect of sorts but not the intended affect. Ill psuedo code it and explain what its doing for me..

register(hamduck, chop)

public chop(id)

speed stuff
convert speed to percentage stuff

new float:speedvec[3]
speedvec[0] = maxspeed
speedvec[1] = maxspeed
speedvec[2] = 0.0

if(conditions to cause my player to slowdown){
set_pev(id, pev_velocity, speedvec)
}

I am not getting the intended behavior, which is for it to slow the player down to the maxspeed... it is instead throwing my player backward sometimes or stopping on a dime. I understand its like because of how I am doing that speedvec and assigning it values, but idk what wizardry i gotta do to ensure its always projecting the player in the proper direction. I have also tried entity_set_float(id, EV_VEC_velocity, speedvec) with the same result.

Shadows Adi 05-05-2021 12:02

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
http://www.amxmodx.org/api/fun/set_user_maxspeed

jimaway 05-05-2021 17:35

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
try this

Code:
limit_velocity(id, value) {     new Float:fvelocity[3]     pev(id, pev_velocity, fvelocity)     new Float:speed = floatsqroot(floatpower(fvelocity[0],2.0) + floatpower(fvelocity[1],2.0))     if(speed > value)     {         new Float:x, Float:y         x = fvelocity[0] / speed         y = fvelocity[1] / speed         fvelocity[0] = x * value         fvelocity[1] = y * value         set_pev(id, pev_velocity, fvelocity)     } }

12Toastie 05-05-2021 18:45

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
Quote:

Originally Posted by Shadows Adi (Post 2746026)

Thank you for your reply! :D

For tfc simply setting the user maxspeed wont cut it because users of chophop are not effected by it. I will need to actually alter their velocity as their maxspeed by default is the maxspeed I want to use anyway. I am trying to reset their velocity BACK to their maxspeed. Was actually the first thing i searched up and tried. I really do appreciate the reply though and hope this doesnt come off foul.

12Toastie 05-05-2021 18:47

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
Thank you!

12Toastie 05-05-2021 20:32

Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
 
Thank you!


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

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