Rules FAQ Members List Search Register Login

 Raised This Month: \$222 Target: \$400 55%

Author Message
12Toastie
Junior Member
Join Date: Nov 2014
 05-05-2021 , 01:52   Looking for a function thatll set the players current velocity.. NOT MAXSPEED #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.
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
 05-05-2021 , 03:02   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED #2 pev_velocity? __________________
12Toastie
Junior Member
Join Date: Nov 2014
 05-05-2021 , 11:25   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED #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.
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
 05-05-2021 , 12:02   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED #4 __________________ Accepting Paid Requests, contact PM. MVP Of The Round View project on GITHUB / AlliedModders CSGO REMAKE ~ CSGO MOD [STABLE]
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
 05-05-2021 , 17:35   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED #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.
12Toastie
Junior Member
Join Date: Nov 2014
05-05-2021 , 18:45   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
#6

Quote:

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
Junior Member
Join Date: Nov 2014
05-05-2021 , 18:47   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED
#7

Quote:
 Originally Posted by jimaway 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)     } }```
damn.. thank you for the pretty much very copy/pastable code hahaha.. i will implement it tonight and let you know how it goes!
12Toastie
Junior Member
Join Date: Nov 2014
 05-05-2021 , 20:32   Re: Looking for a function thatll set the players current velocity.. NOT MAXSPEED #8 ya unfortunately that seemed to have no affect? i threw it in prethink just to see if it would limit at all without conditions and it didnt.. perhaps im calling it wrong? limit_velocity(id, 100.0) is how i called it for testing purposes within prethink 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))     //client_print(0, print_chat, "%f", speed);     //client_print(0, print_chat, "%f", value);     if(speed > value)     {         client_print(0, print_chat, "%f", speed);         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)         } }``` I edited the code to get values.. it gets the speed/value in the function before the statement.. with setting the value at 100.0 and the speed typically being 400.0 at maxspeed it prints out nothing, so for some reason its not getting by that statement. edit: prints if i hard code to value into the function. checking to see if itll work altogether now. So its actually launching me forward right now but at least in the intended direction.. so just gotta inverse it somehow.. but progress! thanks! edit:edit:GOT IT! This is what ended up working for anyone that may be looking for something similar.. thank you for your help! Code: ```limit_velocity(id) {     new Float:fvelocity[3]     pev(id, pev_velocity, fvelocity)     new Float:maxSpeed     pev(id, pev_maxspeed, maxSpeed)     new Float:speed = floatsqroot(floatpower(fvelocity[0],2.0) + floatpower(fvelocity[1],2.0))     //client_print(0, print_chat, "%f", speed);     //client_print(0, print_chat, "%f", value);     if(speed > maxSpeed)     {         //client_print(0, print_chat, "higher");         new Float:x, Float:y         x = fvelocity[0] / speed         y = fvelocity[1] / speed         fvelocity[0] = x * maxSpeed         fvelocity[1] = y * maxSpeed         set_pev(id, pev_velocity, fvelocity)         } }``` Last edited by 12Toastie; 05-05-2021 at 20:57.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

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

 DMCA - Archive - Top