24.07.2015, 04:40
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; }
Please, don't judge me bad, its my first tutorial, hoped it helped.