Events
Client-side
core:setCharacter
This event is triggered when the player character is initialised.
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.
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.
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.
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.
AddEventHandler("core:characterLoaded", function(src, char)
print("Player Id "..src.." has initialised character with Id "..char.get("id"));
end);