[Tutorial] Anti Bunny-Hopping System for your server
#1

Anti Bunny-Hopping System
Code and Tutorial:

Code:
//This should be already included in your script, no worries.
#include <a_samp>

//Add this at bottom of your includes, or organize them on your script.
new BunnyHop[MAX_PLAYERS];
forward SlapPlayer(playerid);
forward TimerBunnyHop(playerid);

//Put this in public OnPlayerConnect
BunnyHop[playerid] = 0;

//Add this on your script.
public SlapPlayer(playerid)
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	SetPlayerPos(playerid, X, Y, Z+5); //The +5 is the slap coords of Z, if you want to get him higher in the sky just incrase it to more.
	BunnyHop[playerid] = 0;
	SendClientMessage(playerid, -1, "{FFFFFF}Bunny Hopping {FF0000}not allowed.");
	return 1;
}


//Add this too. The timer is needed because it have to restore the BunnyHop to 0, if not everytime you press 1 time shift and you press it again in 2 minutes you will get slap.
public TimerBunnyHop(playerid)
{
	BunnyHop[playerid] = 0;
	return 1;
}

//If your script not using any function at public OnPlayerKeyStateChange just copy paste this, or add the strings i've writed for you.
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
 	{
  		if(!IsPlayerInAnyVehicle(playerid))
    	{
       		BunnyHop[playerid] += 1;
         	SetTimer("TimerBunnyHop", 2000, false);
         	if(BunnyHop[playerid] == 2) return SlapPlayer(playerid); //The 2 number means that if he press 2 times in a row shift he will get a slap, you can incrase it to more if you want to.
		}
	}
	return 1;
}
Personal comment:
Please, don't judge me bad, its my first tutorial, hoped it helped.
Reply
#2

Could you elaborate a bit more on why things need to go where they need to go? Also what they do exactly?
Reply
#3

Quote:
Originally Posted by sheNdjze
View Post
Anti Bunny-Hopping System
Code and Tutorial:

Code:
//This should be already included in your script, no worries.
#include <a_samp>

//Add this at bottom of your includes, or organize them on your script.
new BunnyHop[MAX_PLAYERS];
forward SlapPlayer(playerid);
forward TimerBunnyHop(playerid);

//Put this in public OnPlayerConnect
BunnyHop[playerid] = 0;

//Add this on your script.
public SlapPlayer(playerid)
{
	new Float:X, Float:Y, Float:Z;
	GetPlayerPos(playerid, X, Y, Z);
	SetPlayerPos(playerid, X, Y, Z+5); //The +5 is the slap coords of Z, if you want to get him higher in the sky just incrase it to more.
	BunnyHop[playerid] = 0;
	SendClientMessage(playerid, -1, "{FFFFFF}Bunny Hopping {FF0000}not allowed.");
	return 1;
}


//Add this too. The timer is needed because it have to restore the BunnyHop to 0, if not everytime you press 1 time shift and you press it again in 2 minutes you will get slap.
public TimerBunnyHop(playerid)
{
	BunnyHop[playerid] = 0;
	return 1;
}

//If your script not using any function at public OnPlayerKeyStateChange just copy paste this, or add the strings i've writed for you.
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
 	{
  		if(!IsPlayerInAnyVehicle(playerid))
    	{
       		BunnyHop[playerid] += 1;
         	SetTimer("TimerBunnyHop", 2000, false);
         	if(BunnyHop[playerid] == 2) return SlapPlayer(playerid); //The 2 number means that if he press 2 times in a row shift he will get a slap, you can incrase it to more if you want to.
		}
	}
	return 1;
}
Personal comment:
Please, don't judge me bad, its my first tutorial, hoped it helped.
Honestly, All what I see here is "place this here" and "place this below this".

Also, Lets say I'm climbing, I usually r*pe my jump button while climbing, what would you about that ?
Reply
#4

I would suggest to check if the player pressed KEY_UP to increase efficiency of this script.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)