[HELP]Emotes wont trigger

server.lua:

AddEventHandler( 'chatMessage', function( source, n, message )
    if ( message == "/emotes" ) then 
    	CancelEvent()
        TriggerClientEvent( 'showEmotes', source, args[2]);
    end 
end )

AddEventHandler( 'chatMessage', function( source, n, message )
    if ( message == "/emote" ) then 
    	CancelEvent()
        TriggerClientEvent( 'playEmote', source, args[2]);
    end 
end )

client.lua:

RegisterNetEvent('playEmote');
RegisterNetEvent('showEmotes');

-- Emotes, feel free to modify or edit or whatevah!
local emotes = {}
emotes['cop'] = {name = 'cop', anim = 'WORLD_HUMAN_COP_IDLES'}
emotes['binoculars'] = {name = 'binoculars', anim = 'WORLD_HUMAN_BINOCULARS'}
emotes['cheer'] = {name = 'cheer', anim = 'WORLD_HUMAN_CHEERING'}
emotes['drink'] = {name = 'drink', anim = 'WORLD_HUMAN_DRINKING'}
emotes['smoke'] = {name = 'smoke', anim = 'WORLD_HUMAN_SMOKING'}
emotes['film'] = {name = 'film', anim = 'WORLD_HUMAN_MOBILE_FILM_SHOCKING'}
emotes['plant'] = {name = 'plant', anim = 'WORLD_HUMAN_GARDENER_PLANT'}
emotes['guard'] = {name = 'guard', anim = 'WORLD_HUMAN_GUARD_STAND'}
emotes['hammer'] = {name = 'hammer', anim = 'WORLD_HUMAN_HAMMERING'}
emotes['hangout'] = {name = 'hangout', anim = 'WORLD_HUMAN_HANG_OUT_STREET'}
emotes['hiker'] = {name = 'hiker', anim = 'WORLD_HUMAN_HIKER_STANDING'}
emotes['statue'] = {name = 'statue', anim = 'WORLD_HUMAN_HUMAN_STATUE'}
emotes['jog'] = {name = 'jog', anim = 'WORLD_HUMAN_JOG_STANDING'}
emotes['lean'] = {name = 'lean', anim = 'WORLD_HUMAN_LEANING'}
emotes['flex'] = {name = 'flex', anim = 'WORLD_HUMAN_MUSCLE_FLEX'}
emotes['camera'] = {name = 'camera', anim = 'WORLD_HUMAN_PAPARAZZI'}
emotes['sit'] = {name = 'sit', anim = 'WORLD_HUMAN_PICNIC'}
emotes['sitchair'] = {name = 'sitchair', anim = 'PROP_HUMAN_SEAT_CHAIR_MP_PLAYER'}
emotes['hoe'] = {name = 'hoe', anim = 'WORLD_HUMAN_PROSTITUTE_HIGH_CLASS'}
emotes['hoe2'] = {name = 'hoe2', anim = 'WORLD_HUMAN_PROSTITUTE_LOW_CLASS'}
emotes['pushups'] = {name = 'pushups', anim = 'WORLD_HUMAN_PUSH_UPS'}
emotes['situps'] = {name = 'situps', anim = 'WORLD_HUMAN_SIT_UPS'}
emotes['fish'] = {name = 'fish', anim = 'WORLD_HUMAN_STAND_FISHING'}
emotes['impatient'] = {name = 'impatient', anim = 'WORLD_HUMAN_STAND_IMPATIENT'}
emotes['mobile'] = {name = 'mobile', anim = 'WORLD_HUMAN_STAND_MOBILE'}
emotes['diggit'] = {name = 'diggit', anim = 'WORLD_HUMAN_STRIP_WATCH_STAND'}
emotes['sunbath'] = {name = 'sunbath', anim = 'WORLD_HUMAN_SUNBATHE_BACK'}
emotes['sunbath2'] = {name = 'sunbath2', anim = 'WORLD_HUMAN_SUNBATHE'}
emotes['weld'] = {name = 'weld', anim = 'WORLD_HUMAN_WELDING'}
emotes['yoga'] = {name = 'yoga', anim = 'WORLD_HUMAN_YOGA'}
emotes['kneel'] = {name = 'kneel', anim = 'CODE_HUMAN_MEDIC_KNEEL'}
emotes['crowdcontrol'] = {name = 'crowdcontrol', anim = 'CODE_HUMAN_POLICE_CROWD_CONTROL'}
emotes['investigate'] = {name = 'investigate', anim = 'CODE_HUMAN_POLICE_INVESTIGATE'}

playing_emote = false;

local Keys = { ["W"] = 32, ["A"] = 34, ["S"] = 8, ["D"] = 9 }

AddEventHandler('playEmote', function(name)
	if emotes[name] then
		ped = GetPlayerPed(-1);	
		if ped then
			if playing_emote == false then
				if emotes[name].name == "sitchair" then
					pos = GetEntityCoords(ped);
					head = GetEntityHeading(ped);
					TaskStartScenarioAtPosition(ped, emotes[name].anim, pos['x'], pos['y'], pos['z'] - 1, head, 0, 0, false);
				else
					TaskStartScenarioInPlace(ped, emotes[name].anim, 0, true);
				end
				playing_emote = true;

			end
		end
	end
end)

AddEventHandler('showEmotes', function()
	TriggerEvent('chatMessage', "^2MGCRPEmotes", {255, 0, 0}, " (Example: /emote sit)");
	local emoteslist = ""
	for k in pairs(emotes) do
		emoteslist = k .. " ".. emoteslist
	end
	TriggerEvent('chatMessage', "", {255, 0, 0}, emoteslist);
end)


Citizen.CreateThread(function()
	while true do
                Citizen.Wait(0)
		if playing_emote == true then
			if IsControlPressed(1, Keys["W"]) or IsControlPressed(1, Keys["A"]) or IsControlPressed(1, Keys["S"]) or IsControlPressed(1, Keys["D"])  then
				ClearPedTasks(ped);
				playing_emote = false;
			end
		end
        end
end)

You need to load the animations.

how would i do so exactly? is there certain code i need for it?

Handcuff Example

RegisterNetEvent("Handcuff")
AddEventHandler("Handcuff", function()
	local lPed = GetPlayerPed(-1)
	if DoesEntityExist(lPed) then
		if IsEntityPlayingAnim(lPed, "mp_arresting", "idle", 3) then
			ClearPedSecondaryTask(lPed)
			SetEnableHandcuffs(lPed, false)
			SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
		else
			RequestAnimDict("mp_arresting")
			while not HasAnimDictLoaded("mp_arresting") do
				Citizen.Wait(100)
			end

			TaskPlayAnim(lPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
			SetEnableHandcuffs(lPed, true)
			SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
		end
	end
end)

I think you need to use RequestAnimDict.

Edit: @xander1998 beat me to it lol

1 Like

so i have to do that to every animation i have?

Only if the dictionary isn’t already requested.

so would i need to do it to this one?

AddEventHandler('playEmote', function(name)
	if emotes[name] then
		ped = GetPlayerPed(-1);	
		if ped then
			if playing_emote == false then
				if emotes[name].name == "sitchair" then
					pos = GetEntityCoords(ped);
					head = GetEntityHeading(ped);
					TaskStartScenarioAtPosition(ped, emotes[name].anim, pos['x'], pos['y'], pos['z'] - 1, head, 0, 0, false);
				else
					TaskStartScenarioInPlace(ped, emotes[name].anim, 0, true);
				end
				playing_emote = true;

			end
		end
	end
end)

and it also wont display the emotes if i type /emotes

did anyone get this working and is willing to share to the community? I know a lot of people are looking for something like this!

1 Like

@dibzer lol its me again from the m menu modification and leoanim! i am still working on it you will see some progress on the Discord!

the discord is different from the m menu or leoanimations if you want constant updates please join that discord server!

I will be releasing a simple car from bxbugs aswell! it will be out soon im testing it out right now!

1 Like

is there a possible way of doing that because like the vrp phsyco edited has that in their emote.lua file

and it worked on cfxserver but not fxserver how would i get it to work on fx?