Anti-Bunny Hop help
#1

Hello there, i was thinking of creating a simple bunny hop system so i created it but, i dunno if it's good enough for a RP server (a Heavy one) or not... Here it is:
Code:
new BH[MAX_PLAYERS];
forward Bunny_Hop(playerid);
forward Slap(playerid);

public OnPlayerConnect(playerid)
{
  BH[playerid] = 0;
}

public Slap(playerid)
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	SetPlayerPos(playerid, X, Y, Z+5);
	BH[playerid] = 0;
	SendClientMessage(playerid, -1, "Bunny-Hopping is prohibited in this server.");
	return 1;
}

public Bunny_Hop(playerid)
{
	BH[playerid] = 0;
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
 	{
  		if(!IsPlayerInAnyVehicle(playerid))
    	{
     		SetTimer("Bunny_Hop", 2000, false);
       		BH[playerid] += 1;
         	if(BH[playerid] == 2) return Slap(playerid);
		}
	}
	return 1;
}
Please, if you have anything in your mind that could make this script even a little bit better, let me know, i would be thankful of you.
Reply
#2

When I first read about "Bunny Hop", I thought about bmx. Not sure what you want to do, but I'd like to do a sugestion anyways.

• Do not use a timer to reset BH, when you reset it in Slap (kind of pointless).
Reply
#3

Timer is not only for BH reset, it's made to see if the player is pressing Jump repeatedly or not.
Any other idea to make it more Accurate?
Reply
#4

You know, the player can still Bunny Hop but not VERY repeatedly, any idea what to do? please!
Reply
#5

What exactly do you want to do? Not doing bunny hop (with bmx?) repeatedly? If so, you can use GetTickCount instead of timers.
Reply
#6

No, bunny hop on foot..not on BMX...Tapping on JUMP button repeatedly while on foot to get around faster.
Reply
#7

"Bunny Hop" is called for BMX only..

Anyways, pressing the jump key will not make the player goes faster (spacebar does).

If you still want to check about the jump key, in OnPlayerKeyStateChange, if they press the KEY_JUMP, get the tick count. If they press it again, get the tick count again minus the previous tick count and compare the time. If the time is less, let's say (1000-2000 (which is 1-2 seconds)), probably clear the player's animation to stop them from doing that.
Reply
#8

If the character is tired and can't sprint anymore, then bunnyhopping is still faster than the default run.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)