๐Ÿ”ŒIntegrations

This mod is made to be standalone. However, one might want to integrate the user-generated emotes into another animation resource. We currently do not support integrations due to the variety of existing animation features, but it is possible to make these integrations yourself.

If you need help to make these integrations, contact 'unreal_slimshady' on Discord.

Example : Let's say we want to integrate our user generated emotes into the esx_animations resources provided by the ESX Framework.

Their animations are defined like this:

Config = {}

Config.Animations = {

	{
		name  = 'festives',
		label = 'Festives',
		items = {
			{label = "Fumer une cigarette", type = "scenario", data = {anim = "WORLD_HUMAN_SMOKING"}},
			{label = "Jouer de la musique", type = "scenario", data = {anim = "WORLD_HUMAN_MUSICIAN"}},
			{label = "Dj", type = "anim", data = {lib = "anim@mp_player_intcelebrationmale@dj", anim = "dj"}},
			{label = "Boire une biere", type = "scenario", data = {anim = "WORLD_HUMAN_DRINKING"}},
			{label = "Biรจre en zik", type = "scenario", data = {anim = "WORLD_HUMAN_PARTYING"}},
			{label = "Air Guitar", type = "anim", data = {lib = "anim@mp_player_intcelebrationmale@air_guitar", anim = "air_guitar"}},
			{label = "Air Shagging", type = "anim", data = {lib = "anim@mp_player_intcelebrationfemale@air_shagging", anim = "air_shagging"}},
			{label = "Rock'n'roll", type = "anim", data = {lib = "mp_player_int_upperrock", anim = "mp_player_int_rock"}},
			-- {label = "Fumer un joint", type = "scenario", data = {anim = "WORLD_HUMAN_SMOKING_POT"}},
			{label = "Bourrรฉ sur place", type = "anim", data = {lib = "amb@world_human_bum_standing@drunk@idle_a", anim = "idle_a"}},
			{label = "Vomir en voiture", type = "anim", data = {lib = "oddjobs@taxi@tie", anim = "vomit_outside"}},
		}
	},

	{
		name  = 'greetings',
		label = 'Salutations',
		items = {
			{label = "Saluer", type = "anim", data = {lib = "gestures@m@standing@casual", anim = "gesture_hello"}},
			{label = "Serrer la main", type = "anim", data = {lib = "mp_common", anim = "givetake1_a"}},
			{label = "Tchek", type = "anim", data = {lib = "mp_ped_interaction", anim = "handshake_guy_a"}},
			{label = "Salut bandit", type = "anim", data = {lib = "mp_ped_interaction", anim = "hugs_guy_a"}},
			{label = "Salut Militaire", type = "anim", data = {lib = "mp_player_int_uppersalute", anim = "mp_player_int_salute"}},
		}
	},

So, in order to add our content in this resource, we would need to declare it in this config.lua However, they do not provide a way for our resource to interact with it. In order to do that, we could export some encapsulation methods on this resource, to allow other resources to manipulate the data at runtime. In the main.lua file, add the following code :

exports('GetConfig', function()
    return Config
end)

exports('SetConfig', function(newConfig)
    Config = newConfig
end)

Then, we could create in our client/core.lua a method to integrate our content in their configuration, and place it in the handler of the emotes_ready event :

-- Get the configuration
local esx_animations_config = exports['esx_animations']:GetConfig()

-- Format the content
local items = {}
for _, emote in pairs(data) do
	table.insert(items, {label = emote.data.name, icon=iconDOM, type = "anim", data = {lib = emote.data.uuid .. "@animation", anim = "clip"}})
end

local newAnimCategory = {
	name  = 'custom',
	label = 'Custom',
	items = items,
}


-- Try to replace our new "Custom" category
for i, obj in ipairs(esx_animations_config.Animations) do
	if obj.name == "custom" then
		esx_animations_config.Animations[i] = newAnimCategory
		exports['esx_animations']:SetConfig(esx_animations_config)
		return
	end
end

-- Or add it if it does not exist
table.insert(esx_animations_config.Animations, newAnimCategory)

-- Update the configuration
exports['esx_animations']:SetConfig(esx_animations_config)

With this basic example, we can play our emotes with the esx_animations resource!

Last updated