Raised This Month: $12 Target: $400
 3% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
12Toastie
Junior Member
Join Date: Nov 2014
Old 05-05-2021 , 01:52   Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #1

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?

Last edited by 12Toastie; 05-05-2021 at 01:53.
12Toastie is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-05-2021 , 03:02   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #2

pev_velocity?
__________________
HamletEagle is offline
12Toastie
Junior Member
Join Date: Nov 2014
Old 05-05-2021 , 11:25   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #3

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.

Last edited by 12Toastie; 05-05-2021 at 11:27.
12Toastie is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-05-2021 , 12:02   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #4

http://www.amxmodx.org/api/fun/set_user_maxspeed
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-05-2021 , 17:35   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #5

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)     } }

Last edited by jimaway; 05-05-2021 at 17:35.
jimaway is offline
12Toastie
Junior Member
Join Date: Nov 2014
Old 05-05-2021 , 18:45   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #6

Quote:
Originally Posted by Shadows Adi View Post
Thank you for your reply!

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.

Last edited by 12Toastie; 05-05-2021 at 18:46.
12Toastie is offline
12Toastie
Junior Member
Join Date: Nov 2014
Old 05-05-2021 , 18:47   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #7

Thank you!

Last edited by 12Toastie; 07-12-2023 at 04:48.
12Toastie is offline
12Toastie
Junior Member
Join Date: Nov 2014
Old 05-05-2021 , 20:32   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
Reply With Quote #8

Thank you!

Last edited by 12Toastie; 07-12-2023 at 04:48.
12Toastie is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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