Lawliet Posted July 14, 2013 Share Posted July 14, 2013 I'd like to know how one can disable the powersprinting in MTA. For those who do not know what powersprinting is: you powersprint by repeatedly smashing your sprint button. The "stamina" stat you could use needs a special activation flag, but I'm rather new in the "ways" of LUA, so I don't know what "flag" means in this regard. I tried SolidSnake's code snippet... stamina = 10 addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), function () stamina = 10 setTimer(checkKey,700,0) setTimer(updateStamina,1000,0) end) function checkKey() if ( getControlState ( "sprint" ) ) and stamina ~= 0 then stamina = stamina -1 end if ( stamina == 0 ) then setControlState( "sprint", false ) end end function updateStamina() if stamina ~= 10 and getControlState ( "sprint" ) == false then stamina = stamina +1 end end ...however, this only disables the normal sprinting - you can still powersprint even when out of stamina, and that's not exactly what I want. I wrote a small function which checks my movestate every 2 seconds and displays it in chat, and the state seems to be "sprint". Toggling the control won't help either, as a similiar problem arises: While you cannot powersprint anymore when out of stamina, once you regain some, you can again do it, and that continuously, regardless of how high your stamina value is. Recap: - The aforementioned code only disables normal sprint, not powersprint - Toggling controls disables both normal sprint and powersprint, but only until you regain stamina, in which case you can then powersprint, no matter how high your stamina was to that point Is there any way to prevent players from continuously powersprinting? Link to comment
codeluaeveryday Posted July 14, 2013 Share Posted July 14, 2013 CrystalMV, read what he wants again, you are far off topic. Link to comment
DiSaMe Posted July 14, 2013 Share Posted July 14, 2013 Oops, sorry. But still, you need toggleControl for this. And combine it with some other function for actual key state detection, such as bindKey. So pressing the key will not change the running state directly, but instead, the script should detect when it's pressed too quickly and only change the control state when the delay between presses and releases is long enough. Link to comment
Lawliet Posted July 14, 2013 Author Share Posted July 14, 2013 Oops, sorry. But still, you need toggleControl for this. And combine it with some other function for actual key state detection, such as bindKey. So pressing the key will not change the running state directly, but instead, the script should detect when it's pressed too quickly and only change the control state when the delay between presses and releases is long enough. How would such a function look like? As I said, I'm rather new, so something like that might go above my current level of knowledge. Link to comment
Lawliet Posted July 15, 2013 Author Share Posted July 15, 2013 Bumping this topic, I really need to know how to solve this particular issue. Link to comment
VoltBrad Posted July 15, 2013 Share Posted July 15, 2013 I'm still fairly new to LUA but, I'm going to experiment and try to help you. How many clicks of the space bar does it usually take to activate "powersprint" and how long does it usually last? Link to comment
Lawliet Posted July 15, 2013 Author Share Posted July 15, 2013 I'm still fairly new to LUA but, I'm going to experiment and try to help you. How many clicks of the space bar does it usually take to activate "powersprint" and how long does it usually last? Uh, not sure how many taps you need, however, tapping twice in succession usually triggers powersprint. Continue to quickly tap, and you will powersprint ad infinitum (in MTA). Note that not everyone has spacebar as their sprint button, so you might need a function which checks what key the player is using for "sprint". Link to comment
VoltBrad Posted July 16, 2013 Share Posted July 16, 2013 Would you care if I just had it scold you and slap you and tell you not to do it or something like that? I'd like to find an ACTUAL solution but, I can't find anything on it. Atleast until you find a better solution I can just set you up with a punishing system. Kind of like how some servers slap you for bunny hopping. Link to comment
Lawliet Posted July 16, 2013 Author Share Posted July 16, 2013 Would you care if I just had it scold you and slap you and tell you not to do it or something like that? I'd like to find an ACTUAL solution but, I can't find anything on it. Atleast until you find a better solution I can just set you up with a punishing system. Kind of like how some servers slap you for bunny hopping. I would care - it's not like I want to punish those who are powersprinting, I want to prevent it from the beginning. A punishing system is not needed. However, I nevertheless appreciate your willingness to help me out. Link to comment
VoltBrad Posted July 16, 2013 Share Posted July 16, 2013 Yeah I competently understand. I'm honestly used to other mods which don't have as much flexibility and you had to Jerry rig alot of the things you want. I more or less meant like resetting your state so you stop powersprinting not an actual punishment.. I meant in code terms. I'm not sure how to control it as their doesn't appear to be any documentation on it as if it isn't actually addressed by MTA themselves. The only way other then that I see is checking if you spam press the sprint key and dealing with it that way (if hopefully "resetting" your state / teleporting you would actually stop it but, it might not 100% I haven't checked). Preventing it outright though I'm not sure. Sorry I couldn't be of more help. Link to comment
Lawliet Posted July 18, 2013 Author Share Posted July 18, 2013 The only way other then that I see is checking if you spam press the sprint key and dealing with it that way (if hopefully "resetting" your state / teleporting you would actually stop it but, it might not 100% I haven't checked). Preventing it outright though I'm not sure. Sorry I couldn't be of more help. It's not much of an issue if it cannot be prevented in the first place, simply stopping the player from using it is more than sufficient for the intended purpose. Resetting the state of the player might be a good idea - I could use a function which checks the player's speed, and if it surpasses a certain amount, the player will be put into a static animation...that could work out. Thanks for "inspirating" me, I'll see what I can do about that. Suggestions are still more than welcome, though. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now