Skip to main content

Events

Client-side

core:setCharacter

This event is triggered when the player character is initialised.

client/main.lua
AddEventHandler("core:setCharacter", function(charData)
print("Set character with data: "..json.encode(charData));
end);

Server-side

character:createMenu

This event is triggered when a player uses the /swap command to switch characters, and at initial connection.

server/main.lua
AddEventHandler("character:createMenu", function(src)
print("Player Id "..src.." has entered the character selection menu.")
end);

chars:getCharacters

This event takes a callback function as the only argument, which will return the full list of characters. The example below prints the player ID and character name for each character currently instantiated.

server/main.lua
TriggerEvent("chars:getCharacters", function(characters)
for src, char in pairs(characters) do
print("Player Id: "..src);
print("Character Name: "..char.getName());
end
end)
caution

You should use this event to return the table of characters rather than the export GetCharacters. This is because exports have greater limitations to return value size in memory. If you have too many players connected, you may experience errors with using the export.

chars:loadAppearance

This event is used to load an outfit saved for a specific character in the clothing table.

server/main.lua
TriggerEvent("chars:loadAppearance", function(outfitName)
print("Player Id "..source.." has loaded outfit "..outfitName);
end);

core:characterLoaded

This event is triggered when a character has been initialised.

server/main.lua
AddEventHandler("core:characterLoaded", function(src, char)
print("Player Id "..src.." has initialised character with Id "..char.get("id"));
end);