[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


Messages In This Thread
Anti Bunny-Hopping System for your server - by sheNdjze - 24.07.2015, 04:40
Re: Anti Bunny-Hopping System for your server - by [ABK]Antonio - 24.07.2015, 05:30
Re: Anti Bunny-Hopping System for your server - by hossa - 24.07.2015, 06:37
Re: Anti Bunny-Hopping System for your server - by Stanford - 24.07.2015, 11:03

Forum Jump:


Users browsing this thread: 1 Guest(s)