Good idea man.
I will try it and play around. If i find a solution, i will let you know.
That would be nice. Everything works just fine with the command. Only thing that doesn’t work is getting the right skin. So that’s the only “bug” we have at this moment.
Keep me updated! 
I used that and it works great, you just need to add the
TriggerClientEvent(“kashactersC:Skinchanger”, src)
in the server side and the
RegisterNetEvent(‘kashactersC:Skinchanger’)
AddEventHandler(‘kashactersC:Skinchanger’, function(source)
local source_ = source
ESX.TriggerServerCallback(‘esx_skin:getPlayerSkin’, function(skin, jobSkin)
TriggerEvent(‘skinchanger:loadSkin’, skin)
end)
end)
to the client side.
So the CharacterChosen is already in the server side event right ?
So im adding the Skinchanger in the client and the trigger the command with CharacterChosen ?
EDIT: Well i guess thats not what you mean, because it doesnt do anything for me.
I have no idea where to put what.
Can you help me out ?
Sure, Server side:
You replace the
RegisterServerEvent("kashactersS:CharacterChosen")
AddEventHandler('kashactersS:CharacterChosen', function(charid, ischar)
local src = source
local spawn = {}
SetLastCharacter(src, tonumber(charid))
SetCharToIdentifier(GetPlayerIdentifiers(src)[1], tonumber(charid))
if ischar == "true" then
spawn = GetSpawnPos(src)
else
TriggerClientEvent('skinchanger:loadDefaultModel', src, true, cb)
spawn = { x = -268.63, y = -956.94, z = 31.22 } -- DEFAULT SPAWN POSITION
end
TriggerClientEvent("kashactersC:SpawnCharacter", src, spawn)
end)
for
RegisterServerEvent("kashactersS:CharacterChosen")
AddEventHandler('kashactersS:CharacterChosen', function(charid, ischar)
local src = source
local spawn = {}
SetLastCharacter(src, tonumber(charid))
SetCharToIdentifier(GetPlayerIdentifiers(src)[1], tonumber(charid))
if ischar == "true" then
spawn = GetSpawnPos(src)
TriggerClientEvent("kashactersC:Skinchanger", src) -- THIS IS THE NEW THING
else
TriggerClientEvent('skinchanger:loadDefaultModel', src, true, cb)
spawn = { x = -268.63, y = -956.94, z = 31.22 } -- DEFAULT SPAWN POSITION
end
TriggerClientEvent("kashactersC:SpawnCharacter", src, spawn)
end)
you just added " TriggerClientEvent("kashactersC:Skinchanger", src)".
In the Client side:
Just add:
RegisterNetEvent('kashactersC:Skinchanger')
AddEventHandler('kashactersC:Skinchanger', function(source)
local source_ = source
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
TriggerEvent('skinchanger:loadSkin', skin)
end)
end)
add that anywhere in the client side.
So i guess the command stays ReloadCharacters or did i miss anything ?
for the command you use
RegisterCommand('switch', function()
TriggerEvent('kashactersC:ReloadCharacters')
end)
You can use switch or whatever you want, add that in the client side anywhere.
Making a new Char still shows the old skin, and brings everything over to the new player.
- I see a error in the console.
@esx_skin: attempt to index a nil value (local ‘xPlayer’)
EDIT: The nil value problem is solved.
Anyone know the fix for the property showing the same from char 1 on all characters properties? Need a fix asap! Thank you! ps i looked through the whole post.
make sure you have the
{table = "owned_properties", column = "owner"},
in the server side.
I have no idea about that… i didnt have that problem, are you using the lastest version of mysql-async?
It’s in there, not quite sure what the problem is, there’s no errors also
Yes, updated today.
So how come when i use /switch and choose to make a new char it still shows the old skin ?
The switching it self works fine, if i did not made the new char with the /switch
How can i restrict to max 1 char?
what’s the point in using Multi character script and restricting it to 1 character?
just remove the script xD
but if you want to restrict it to 1 character check the html file your answer is there.
I turned of all the esx_indentity chat commands.
Didnt see any error or problems yet.
dude, that changed my life right there… switching player is now done in seconds… i think i love you!
EDIT: on another subject, has this script been tested with 5+ characters… the code seem expendable… are there other limitation ?
hi i am getting this error from the console after doing this
Error running call reference function for resource esx_skin: citizen:/scripting/lua/scheduler.lua:405: @esx_skin/server/main.lua:39: attempt to index a nil value (local ‘xPlayer’)
stack traceback:
@esx_skin/server/main.lua:39: in upvalue ‘ref’
citizen:/scripting/lua/scheduler.lua:391: in function citizen:/scripting/lua/scheduler.lua:390
[C]: in function ‘xpcall’
citizen:/scripting/lua/scheduler.lua:390: in function citizen:/scripting/lua/scheduler.lua:389
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:405: in function citizen:/scripting/lua/scheduler.lua:374
Error running system event handling function for resource es_extended: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/MessagePack.lua:830: in method ‘underflow’
citizen:/scripting/lua/MessagePack.lua:465: in field ‘any’
citizen:/scripting/lua/MessagePack.lua:860: in field ‘unpack’
citizen:/scripting/lua/scheduler.lua:628: in field ‘?’
@es_extended/server/functions.lua:33: in field ‘TriggerServerCallback’
@es_extended/server/common.lua:63: in upvalue ‘handler’
citizen:/scripting/lua/scheduler.lua:219: in function citizen:/scripting/lua/scheduler.lua:218
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:41: in field ‘CreateThreadNow’
citizen:/scripting/lua/scheduler.lua:218: in function citizen:/scripting/lua/scheduler.lua:182
Sending heartbeat to live-internal.fivem.net:30110
Sending heartbeat to live-internal.fivem.net:30110
Just a hint, i bet its only happening to you on your first spawn…
if you comment the line
TriggerClientEvent(“kashactersC:Skinchanger”, src)
and restart your server, it will be gone.
Since you need it to trigger when you are going to use /switch … otherwise you stay inside your last skin when switching
TriggerClientEvent(“kashactersC:Skinchanger”, src) is not needed on spawn… for me. which was triggering the same error you had.