Gang Animation

Able to move now but the animation it self is a bit more clunky. Im grabbing the gun from the front and working my way from the front to the back almost like its opposite. Is there anything that can be done about that? Thank you for the help.

From what I have seen so far, not a huge ton, as it checks what your current weapon is and then if it matches against the array it plays the anim. The only fix I have found is changing the flag back to standing still.

Hmmm strange I wonder how people over at nopixel got it working because ive seen them able to move while taking the gun from the back perfectly as seen here https://www.twitch.tv/videos/422088144?t=07h59m49s

Also If I wanted civilians to use this animation but cops using something else like this [Release][ESX & Non-ESX] Holster Weapon would you know the way around this?

Like this?

If that doesn’t work - https://streamable.com/z5ng5

1 Like

Ive been trying to figure out how to do it, but if its possible to get the animation like the one you did in the video WHILE moving around. That would be PERFECT. Thank you again for taking the time and trying to help <3.

Thank you so much! Currently as this doesn’t allow you to run I use this which I see you developed [Release][ESX & Non-ESX] Holster Weapon what would be really cool or what I wish is for civilians to use the “gangster” animation to pull pistols from the back, and the police to use the “weapon holster” animation as that makes more sense like real life. If that’s also somehow possible that would be PERFECT. Again thank you for looking into it :smiley:

The link is broken

Script would be perfect if the player was forced to play the anim EVERY time he equip new weapon not just Melee <> Gun switch.

Do you have an idea how to make the gun appears in the hand after the anim is half-played?

I think I am going to rewrite this as the current method isn’t that great, it checks if you have the weapon then plays the animation, which isn’t that great.

I would really appreciate if you do that because I was trying different things but can’t make it work like I said before :confused:

Can you share these lines please, this is exactly was i was looking for!

Here’s my script, I haven’t done a huge amount of testing so I’m sure there’s things that could be done better.

It’s a modified version of https://github.com/FiveM-Dev-Sverige/weapon_switch_anim
(0 idea if this was taken from elsewhere, but that’s the repo I started from)

If you have a weapon that you’re wanting the anim to play already equipped, and switch to another one it’ll play both animations. If you go from one that is set to play to one that isn’t it should play the outro and then equip the new weapon.

Again, I’ve done all of 0 testing on this outside of when I was making it so if something is broke I have no idea. You’ve been warned.

local weapons = {
	'WEAPON_KNIFE',
	'WEAPON_NIGHTSTICK',
	'WEAPON_HAMMER',
	'WEAPON_BAT',
	'WEAPON_GOLFCLUB',
	'WEAPON_CROWBAR',
	'WEAPON_BOTTLE',
	'WEAPON_DAGGER',
	'WEAPON_HATCHET',
	'WEAPON_MACHETE',
	'WEAPON_SWITCHBLADE',
	'WEAPON_BATTLEAXE',
	'WEAPON_POOLCUE',
	'WEAPON_WRENCH',
	'WEAPON_PISTOL',
	'WEAPON_COMBATPISTOL',
	'WEAPON_APPISTOL',
	'WEAPON_PISTOL50',
	'WEAPON_REVOLVER',
	'WEAPON_SNSPISTOL',
	'WEAPON_HEAVYPISTOL',
	'WEAPON_VINTAGEPISTOL',
	'WEAPON_MICROSMG',
	'WEAPON_SMG',
	'WEAPON_ASSAULTSMG',
	'WEAPON_MINISMG',
	'WEAPON_MACHINEPISTOL',
	'WEAPON_COMBATPDW',
	'WEAPON_PUMPSHOTGUN',
	'WEAPON_SAWNOFFSHOTGUN',
	'WEAPON_ASSAULTSHOTGUN',
	'WEAPON_BULLPUPSHOTGUN',
	'WEAPON_HEAVYSHOTGUN',
	'WEAPON_ASSAULTRIFLE',
	'WEAPON_CARBINERIFLE',
	'WEAPON_ADVANCEDRIFLE',
	'WEAPON_SPECIALCARBINE',
	'WEAPON_BULLPUPRIFLE',
	'WEAPON_COMPACTRIFLE',
	'WEAPON_MG',
	'WEAPON_COMBATMG',
	'WEAPON_GUSENBERG',
	'WEAPON_SNIPERRIFLE',
	'WEAPON_HEAVYSNIPER',
	'WEAPON_MARKSMANRIFLE',
	'WEAPON_GRENADELAUNCHER',
	'WEAPON_RPG',
	'WEAPON_STINGER',
	'WEAPON_MINIGUN',
	'WEAPON_GRENADE',
	'WEAPON_STICKYBOMB',
	'WEAPON_SMOKEGRENADE',
	'WEAPON_BZGAS',
	'WEAPON_MOLOTOV',
	'WEAPON_DIGISCANNER',
	'WEAPON_FIREWORK',
	'WEAPON_MUSKET',
	'WEAPON_STUNGUN',
	'WEAPON_HOMINGLAUNCHER',
	'WEAPON_PROXMINE',
	'WEAPON_FLAREGUN',
	'WEAPON_MARKSMANPISTOL',
	'WEAPON_RAILGUN',
	'WEAPON_DBSHOTGUN',
	'WEAPON_AUTOSHOTGUN',
	'WEAPON_COMPACTLAUNCHER',
	'WEAPON_PIPEBOMB',
	'WEAPON_DOUBLEACTION',
}

local holstered = true
local canfire = true
local currWeapon = nil

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if DoesEntityExist( GetPlayerPed(-1) ) and not IsEntityDead( GetPlayerPed(-1) ) and not IsPedInAnyVehicle(PlayerPedId(-1), true) then
			if currWeapon ~= GetSelectedPedWeapon(GetPlayerPed(-1)) then
				pos = GetEntityCoords(GetPlayerPed(-1), true)
				rot = GetEntityHeading(GetPlayerPed(-1))

				local newWeap = GetSelectedPedWeapon(GetPlayerPed(-1))
				SetCurrentPedWeapon(GetPlayerPed(-1), currWeapon, true)
				loadAnimDict( "reaction@intimidation@1h" )

				if CheckWeapon(newWeap) then
					if holstered then
						canFire = false
						TaskPlayAnimAdvanced(GetPlayerPed(-1), "reaction@intimidation@1h", "intro", GetEntityCoords(GetPlayerPed(-1), true), 0, 0, rot, 8.0, 3.0, -1, 50, 0.325, 0, 0)
						SetCurrentPedWeapon(GetPlayerPed(-1), newWeap, true)
						Citizen.Wait(600)
						ClearPedTasks(GetPlayerPed(-1))
						holstered = false
						canFire = true
						currWeapon = newWeap
					elseif newWeap ~= currWeapon then
						canFire = false
						TaskPlayAnimAdvanced(GetPlayerPed(-1), "reaction@intimidation@1h", "outro", GetEntityCoords(GetPlayerPed(-1), true), 0, 0, rot, 8.0, 3.0, -1, 50, 0.125, 0, 0)
						Citizen.Wait(500)
						ClearPedTasks(GetPlayerPed(-1))
						TaskPlayAnimAdvanced(GetPlayerPed(-1), "reaction@intimidation@1h", "intro", GetEntityCoords(GetPlayerPed(-1), true), 0, 0, rot, 8.0, 3.0, -1, 50, 0.325, 0, 0)
						SetCurrentPedWeapon(GetPlayerPed(-1), newWeap, true)
						Citizen.Wait(600)
						ClearPedTasks(GetPlayerPed(-1))
						holstered = false
						canFire = true
						currWeapon = newWeap
					end
				else
					if not holstered then
						canFire = false
						TaskPlayAnimAdvanced(GetPlayerPed(-1), "reaction@intimidation@1h", "outro", GetEntityCoords(GetPlayerPed(-1), true), 0, 0, rot, 8.0, 3.0, -1, 50, 0.125, 0, 0)
						Citizen.Wait(500)
						SetCurrentPedWeapon(GetPlayerPed(-1), newWeap, true)
						ClearPedTasks(GetPlayerPed(-1))
						holstered = true
						canFire = true
						currWeapon = newWeap
					else
						canFire = false
						TaskPlayAnimAdvanced(GetPlayerPed(-1), "reaction@intimidation@1h", "intro", GetEntityCoords(GetPlayerPed(-1), true), 0, 0, rot, 8.0, 3.0, -1, 50, 0.325, 0, 0)
						SetCurrentPedWeapon(GetPlayerPed(-1), newWeap, true)
						Citizen.Wait(600)
						ClearPedTasks(GetPlayerPed(-1))
						holstered = false
						canFire = true
						currWeapon = newWeap
					end
				end
			end
		end
	end
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if not canFire then
			DisableControlAction(0, 25, true)
			DisablePlayerFiring(GetPlayerPed(-1), true)
		end
	end
end)

function CheckWeapon(newWeap)
	for i = 1, #weapons do
		if GetHashKey(weapons[i]) == newWeap then
			return true
		end
	end
	return false
end

function loadAnimDict(dict)
	while (not HasAnimDictLoaded(dict)) do
		RequestAnimDict(dict)
		Citizen.Wait(5)
	end
end
5 Likes

Nice dude!, thanks for this

There is one issue, if i remove weapon’s for the list, they still play the animation, do you know how to fix that?

works just like the others you stand still while playing the animation

works fine on my end, i can walk while doing the animation, the only thing with me is that if i take a weapon out of the list, it won’t make a difference cuz it’l still play the animation on that weapon

Thank you so so much!
Perfect for me

Splendid job my man. I was trying to do it on my own but didn’t success.

That’s something on your end, works while moving for me. Check that you’re setting the animation flags.

Honestly not sure, that’s strange but don’t have time right now to look into it. Will try to check it this weekend.