Jump to content

save-system for skin problem


Cronoss

Recommended Posts

well, it's me again, I got a new problem with my skin-system, I wanted to make a save-system for the skin, the save-system itself works, it remember the name of the player, BUT not the skin, here it's the code:

When I login the game sets me the CJ default skin

(server-side)

function recordarPersonaje()
	local cuentaJugador = getPlayerAccount(source)
	if (cuentaJugador) and not isGuestAccount(cuentaJugador) then
		local personajeDatos = getPlayerName(source)
		local skinPJ = getElementModel(source)
		setAccountData(cuentaJugador, "nombre", personajeDatos)
		setAccountData(cuentaJugador, "skin", skinPJ)
	end
end

function darDatos(_, cuentaJugador)
	if (cuentaJugador) then
		local skinJugadorDar = getAccountData(cuentaJugador, "skin")
		local nombreJugadorDar = getAccountData(cuentaJugador, "nombre")
		if (nombreJugadorDar) then
			setPlayerName(source, nombreJugadorDar)
			setElementModel(source, skinJugadorDar)
		end
	end
end

addEventHandler("onPlayerQuit", root, recordarPersonaje)
addEventHandler("onPlayerLogin", root, darDatos)

I just need to know if I'm doing something wrong or there is another method to remember the skin of the player that i'm missing

(PD: the option to set the player skin is in server-side too, I tested with another player, and we both can see eachother skin when we choose it, so I really don't understand what's wrong)

Link to comment

this issue will not work if done before spawning player using spawnPlayer function

so make sure the player spawn

example:

addEventHandler("onPlayerJoin", root,
    function()
       setElementModel(source, 10) --will not work because the player did not spawn
       spawnPlayer(source, 0, 0, 3)
    end
)

 

addEventHandler("onPlayerJoin", root,
    function()
       spawnPlayer(source, 0, 0, 3)
       setElementModel(source, 10) --it will work
    end
)

 

Edited by Burak5312
  • Like 1
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...