SA-MP Forums Archive
Anti-Bunny Hop help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti-Bunny Hop help (/showthread.php?tid=464492)



Anti-Bunny Hop help - alinategh - 17.09.2013

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.


Re: Anti-Bunny Hop help - Konstantinos - 17.09.2013

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).


Re: Anti-Bunny Hop help - alinategh - 17.09.2013

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?


Re: Anti-Bunny Hop help - alinategh - 17.09.2013

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


Re: Anti-Bunny Hop help - Konstantinos - 17.09.2013

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


Re: Anti-Bunny Hop help - alinategh - 17.09.2013

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


Re: Anti-Bunny Hop help - Konstantinos - 17.09.2013

"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.


Re: Anti-Bunny Hop help - Vince - 17.09.2013

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