I'm trying to use the setPlayerAppearance export with FiveM's internal kvs. Saving to the database is fine but trying to set the player appearance after spawn isn't proving effective..
Event to save the skin:
RegisterNetEvent('updatecharacterclothes')
AddEventHandler('updatecharacterclothes', function(appearance)
local identifier = GetIdentifier(source)
SetResourceKvp(('users:%s:outfit_current'):format(identifier), json.encode(appearance))
print('outfit saved to db')
end)
Function to retrieve the skin:
function GetCharSkin(source)
local source = source
local identifier = GetIdentifier(source)
local appearance = GetResourceKvpString(('users:%s:outfit_current'):format(identifier))
local charappearance = json.decode(appearance)
return charappearance
end
I'm using this handler:
AddEventHandler('playerSpawned', function()
To trigger the server event that gets the saved data and using this event to try load it from the client:
Hi there!
I'm trying to use the setPlayerAppearance export with FiveM's internal kvs. Saving to the database is fine but trying to set the player appearance after spawn isn't proving effective..
Event to save the skin:
Function to retrieve the skin:
I'm using this handler:
AddEventHandler('playerSpawned', function()
To trigger the server event that gets the saved data and using this event to try load it from the client:
However, 'Default Dan' is loaded each time. No errors in the console, and the prints show each event running as they should.
Everything is standalone from any framework
Any suggestion?
EDIT: I overlooked the fact the export takes two params, so to anyone reading thism the correct syntax for me was:
exports["fivem-appearance"]:setPlayerAppearance(source, appearance)