Unlimited sprinting -
Zitteke - 23.05.2014
Hello,
I have (probably) have a simple question. I would like to add a system that makes you sprint for an infinite time as long as you're pressing the KEY_SPRINT & KEY_UP (forward) button at the same time.
I did find a few examples, but none really did what I wanted. I did try something like this, but it didn't really work out the way I wanted:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (HOLDING( KEY_SPRINT | KEY_UP ))
{
ApplyAnimation(playerid, "PED", "sprint_civi", 4.1, 1, 1, 1, 1, 1, 1);
}
}
(
https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange)
I hope someone can help me. I would like to see a pre-made script since I've been looking for something like this for a while now, and I couldn't really find anything that works the way I want it to.
I think it is possible by applying an animation, but it's just not working for me right now.
Thank you.
Re : Unlimited sprinting -
S4t3K - 23.05.2014
Try replacing your condition with that
PHP код:
if(HOLDING(KEY_SPRINT) && HOLDING(KEY_FIRE))
Also, don't forget to return something (0 or 1) to the OnPlayerKeyStateChange callback.
Re: Unlimited sprinting -
Zitteke - 23.05.2014
That didn't seem to work.
When looking at the wiki it does also say that you need to do:
Код:
if (HOLDING( KEY_FIRE | KEY_CROUCH ))
But even that didn't work for me. (I did try also try it with return 1, return 0, both inside and outside the if-statement).
Re: Unlimited sprinting -
SickAttack - 23.05.2014
I think that this won't work because the player will have to hold down both keys. And if you play like me, then it won't work wat all, because I tap space ._.
Re: Unlimited sprinting -
Zitteke - 23.05.2014
Quote:
Originally Posted by SickAttack
I think that this won't work because the player will have to hold down both keys. And if you play like me, then it won't work wat all, because I tap space ._.
|
If there's another way to do this then that would be fine too. But as far as I know SA-MP doesn't natively support something like this.
Re : Unlimited sprinting -
S4t3K - 23.05.2014
Nice observation.
Change KEY_SPRINT to KEY_NO for example.
Re: Unlimited sprinting -
Zitteke - 23.05.2014
It seems like it's just not working at all. Maybe there's a way to put the 'run energy' back to 0 or however that works? Or to change the skill level which makes you run forever.
I don't really need it, but it would be a nice addition for my server. So if it doesn't work then it doesn't work lol.
Re: Unlimited sprinting -
Denying - 23.05.2014
If you want to somewhat regenerate the player's stamina so he could run after getting tired, you could get the player's coordinates every once in a while (while he's sprinting of course) and respawn him at that location, which will regenerate his stamina.