SA-MP Forums Archive
[FilterScript] Simple Dodge system by !Pumpkin - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Simple Dodge system by !Pumpkin (/showthread.php?tid=606748)



Simple Dodge system by !Pumpkin - !Pumpkin - 08.05.2016

So this is a simple dodge system.
Just press RMB+Crouch to dodge.

https://*********/6bGMybk8iT4
http://pastebin.com/mFF3W8u3

Code:
#include <a_samp>

#define KEY_AIM			(128)
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

PreloadAnimLib(playerid, animlib[])
{
	ApplyAnimation(playerid,animlib,"null",0.0,0,0,0,0,0);
}

public OnFilterScriptInit()
{
	print("\n--------------------------------------");
	print(" Simple dodge system by !Pumpkin reloaded");
	print("--------------------------------------\n");
	return 1;
}

public OnFilterScriptExit()
{
	print("\n--------------------------------------");
	print(" Simple dodge system by !Pumpkin unloaded");
	print("--------------------------------------\n");
	return 1;
}

	public OnPlayerSpawn(playerid)
{
	PreloadAnimLib(playerid,"PED");
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new playerState = GetPlayerState(playerid); // Get the killer's state
    if(playerState == PLAYER_STATE_ONFOOT) // If the killer was in a vehicle
    {
	if (PRESSED( KEY_CROUCH | KEY_AIM ))
	{
	ApplyAnimation(playerid, "PED", "EV_dive", 4.1, 0, 1, 1, 1, 5, 1);
	}
	}
	return 1;
}