Hulgore Posted January 12 Share Posted January 12 Hello, I am trying to make a sprint key by using the ModPCMovementSpeed function, and would like to figure out a way to reset that modifier in case it is applied for a reason or another when the key is not pressed. This is the reset block I made using GetPCMovementSpeedModifier function : ; Reset the Speed Modifier if applied for no reason if KeyPress == 0 && Check == 0 && GetPCMovementSpeedModifier == 60 ; if sprint key is not pressed, but sprint bonus of 60 is somehow applied ModPCMovementSpeed -60 Message "Speed Modifier Reset" endif Is this going to work ? Link to comment Share on other sites More sharing options...
GamerRick Posted January 13 Share Posted January 13 (edited) Try changing "&& GetPCMovementSpeedModifier == 60" to "&& GetPCMovementSpeedModifier != 0" Maybe, for some reason the modifier (being a float) is not exactly 60. Edit#1: Next I would try this: float SpeedMod ; Reset the Speed Modifier if applied for no reason set SpeedMod to GetPCMovementSpeedModifier PrintC "SpeedMod = %f Keypress = %g Check = %g", SpeedMod, KeyPress, Check ; NOTE this may flood the console depending on how often it's hit if KeyPress == 0 && Check == 0 && SpeedMod != 0 ; if sprint key is not pressed, but sprint bonus of 60 is somehow applied set SpeedMod to SpeedMod * -1.0 ModPCMovementSpeed SpeedMod Message "Speed Modifier Reset" endif Edited January 13 by GamerRick because Link to comment Share on other sites More sharing options...
RomanR Posted January 13 Share Posted January 13 (edited) Instead of assigning extra key it would be better to apply speed when we want player to move and he is already in run mode? short speedMod ... if IsControlDisabled 0 == 0 ;0 - forward control available if IsControlPressed 0 != 0 && player.IsRunning != 0 if speedMod == 0 ModPCMovementSpeed 60 set speedMod to 1 endif elseif speedMod != 0 ModPCMovementSpeed -60 set speedMod to 0 endif else ;if not if speedMod != 0 ;return speed if mod applied ModPCMovementSpeed -60 set speedMod to 0 endif endif ... Also don't forget that function variables get reseted after every run, so the ones you need to remember must be saved elsewhere, like in quest or global variables. Edited January 16 by RomanR typos and bugfix Link to comment Share on other sites More sharing options...
Hulgore Posted January 15 Author Share Posted January 15 Thank you for your answers, sorry for my late reply, I'm going to have a look at that Link to comment Share on other sites More sharing options...
RomanR Posted January 16 Share Posted January 16 I'm sorry, but I noticed a bug in my script post. I forgot to add a check if speedMod variable is at zero when adding speed, without it speed would add always when holding a forward control key. See this post again please. Link to comment Share on other sites More sharing options...
Recommended Posts