Furious Posted February 24, 2019 Author Share Posted February 24, 2019 1 minute ago, Dimos7 said: You want player has login or before login? I want before the login. Link to comment
Dimos7 Posted February 24, 2019 Share Posted February 24, 2019 function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = tonumber(getAccountData(playerAcc, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) Try this Link to comment
Furious Posted February 24, 2019 Author Share Posted February 24, 2019 7 minutes ago, Dimos7 said: function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = tonumber(getAccountData(playerAcc, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", localPlayer) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) Try this [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:61: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:61: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got boolean] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:62: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:63: Bad argument @ 'createPed' [Expected bool at argument 6, got number '0'] Link to comment
Dimos7 Posted February 24, 2019 Share Posted February 24, 2019 function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = getAccountData(playerAcc, "skin") setElementData(thePlayer, "skin", playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", resourceRoot) local playerSkin = tonumber(getElementData(localPlayer, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) If that not work i give up Link to comment
Furious Posted February 24, 2019 Author Share Posted February 24, 2019 (edited) 16 minutes ago, Dimos7 said: function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = getAccountData(playerAcc, "skin") setElementData(thePlayer, "skin", playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", resourceRoot) local playerSkin = tonumber(getElementData(localPlayer, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) If that not work i give up Black screen, This time I give up, better make another input panel. Edited February 24, 2019 by MatheusCalixto Link to comment
Dimos7 Posted February 24, 2019 Share Posted February 24, 2019 (edited) function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = getAccountData(playerAcc, "skin") setElementData(thePlayer, "skin", playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", resourceRoot, localPlayer ) local playerSkin = tonumber(getElementData(localPlayer, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) Edited February 24, 2019 by Dimos7 Link to comment
KillerX Posted February 24, 2019 Share Posted February 24, 2019 50 minutes ago, MatheusCalixto said: triggerServerEvent("makePed", resourceRoot) triggerServerEvent("makePed", resourceRoot , localPlayer ) 1 minute ago, Dimos7 said: triggerServerEvent("makePed", localPlayer ) localPlayer = source Link to comment
Dimos7 Posted February 24, 2019 Share Posted February 24, 2019 2 minutes ago, KillerX said: triggerServerEvent("makePed", resourceRoot , localPlayer ) localPlayer = source I know thank you 1 Link to comment
Mr.Loki Posted February 24, 2019 Share Posted February 24, 2019 Server Spoiler local lastSkinTable = {} addEventHandler( "onPlayerQuit", root, function( ) local serial = getPlayerSerial( source ) lastSkinTable[serial] = getElementModel( source ) end ) local filePath = "skinDB.json" addEventHandler( "onResourceStart", resourceRoot, function( ) local db = fileExists( filePath ) and fileOpen( filePath ) if not db then return end lastSkinTable = fromJSON( fileRead( db, fileGetSize( db ) ) ) fileClose( db ) end ) addEventHandler( "onResourceStop", resourceRoot, function( ) local db = fileExists( filePath ) and fileOpen( filePath ) or fileCreate( filePath ) fileWrite( db, toJSON( lastSkinTable ) ) fileClose( db ) end ) addEvent( "onRequestLastSkin", true ) addEventHandler( "onRequestLastSkin", root, function( ) local serial = getPlayerSerial( source ) triggerClientEvent( source, "onGetLastSkin", source, lastSkinTable[serial] ) end ) Client Spoiler addEventHandler( "onClientResourceStart", resourceRoot, function( ) triggerServerEvent( "onRequestLastSkin", localPlayer ) end ) addEvent( "onGetLastSkin", true ) addEventHandler( "onGetLastSkin", root, function( skinID ) local ped = createPed((skinID or 0),-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end ) Link to comment
Furious Posted February 24, 2019 Author Share Posted February 24, 2019 19 minutes ago, Dimos7 said: function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(getPlayerName(thePlayer)) local playerSkin = getAccountData(playerAcc, "skin") setElementData(thePlayer, "skin", playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", resourceRoot, localPlayer ) local playerSkin = tonumber(getElementData(localPlayer, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) Please see your inbox. Link to comment
Dimos7 Posted February 25, 2019 Share Posted February 25, 2019 (edited) function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(thePlayer) local playerSkin = getAccountData(playerAcc, "skin") setElementData(thePlayer, "skin", playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", resourceRoot, localPlayer) local playerSkin = tonumber(getElementData(localPlayer, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEventHandler("onClientResourceStart", resourceRoot, onPlayerCheckSkin) Edited February 25, 2019 by Dimos7 Link to comment
Furious Posted February 25, 2019 Author Share Posted February 25, 2019 (edited) Spoiler 3 hours ago, Dimos7 said: 5 hours ago, Mr.Loki said: Servidor Revelar conteúdos ocultos local lastSkinTable = {} addEventHandler( "onPlayerQuit", root, function( ) local serial = getPlayerSerial( source ) lastSkinTable[serial] = getElementModel( source ) end ) local filePath = "skinDB.json" addEventHandler( "onResourceStart", resourceRoot, function( ) local db = fileExists( filePath ) and fileOpen( filePath ) if not db then return end lastSkinTable = fromJSON( fileRead( db, fileGetSize( db ) ) ) fileClose( db ) end ) addEventHandler( "onResourceStop", resourceRoot, function( ) local db = fileExists( filePath ) and fileOpen( filePath ) or fileCreate( filePath ) fileWrite( db, toJSON( lastSkinTable ) ) fileClose( db ) end ) addEvent( "onRequestLastSkin", true ) addEventHandler( "onRequestLastSkin", root, function( ) local serial = getPlayerSerial( source ) triggerClientEvent( source, "onGetLastSkin", source, lastSkinTable[serial] ) end ) Cliente Revelar conteúdos ocultos addEventHandler( "onClientResourceStart", resourceRoot, function( ) triggerServerEvent( "onRequestLastSkin", localPlayer ) end ) addEvent( "onGetLastSkin", true ) addEventHandler( "onGetLastSkin", root, function( skinID ) local ped = createPed((skinID or 0),-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end ) 5 hours ago, KillerX said: localPlayer = source Guys, after a long time I figured out what it was, the temporary files, were conflicting with the server files. Thank you all! I used the example of: Mr.Loki But I'm sure the example of: Dimos7, is running too! Code that worked, I did not want to store the skins and even then the code worked. -- Server-side addEventHandler( "onPlayerQuit", root, function( ) local serial = getPlayerSerial( source ) lastSkinTable[serial] = getElementModel( source ) outputDebugString(lastSkinTable[serial]) end ) addEvent( "onRequestLastSkin", true ) addEventHandler( "onRequestLastSkin", root, function( ) local serial = getPlayerSerial( source ) triggerClientEvent( source, "onGetLastSkin", source, lastSkinTable[serial] ) end ) --Client-side addEvent( "onGetLastSkin", true ) addEventHandler( "onGetLastSkin", root, function( skinID ) local ped = createPed((skinID or 0),-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end ) Edited February 25, 2019 by MatheusCalixto Link to comment
Dimos7 Posted February 25, 2019 Share Posted February 25, 2019 (edited) function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(thePlayer) local playerSkin = tonumber (getAccountData(playerAcc, "skin")) triggerClientEvent(thePlayer, "makePed", root, playerSkin) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin(playerSkin) triggerServerEvent("makePed", root , localPlayer) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end addEvent("makePed", true) addEventHandler("makePed", root , onPlayerCheckSkin) Edited February 25, 2019 by Dimos7 Link to comment
Dimos7 Posted February 26, 2019 Share Posted February 26, 2019 (edited) function onPlayerSaveSkin() local playerAcc = getPlayerAccount(source) if not isGuestAccount(playerAcc) then local playerSkin = getElementModel(source) setAccountData(playerAcc, "skin", tostring(playerSkin)) end end addEventHandler("onPlayerQuit", root, onPlayerSaveSkin) function onPlayerLoadSkin(thePlayer) local playerAcc = getPlayerAccount(thePlayer) local playerSkin = tonumber (getAccountData(playerAcc, "skin")) createPed(playerSkin or 0 ,-1600.9000244141,-1620.6999511719,36.599998474121,0) end addEvent("makePed", true) addEventHandler("makePed", root, onPlayerLoadSkin) function onPlayerCheckSkin() triggerServerEvent("makePed", root , localPlayer) end addEventHandler("onClientResourceStart", resourceRoot , onPlayerCheckSkin) Edited February 26, 2019 by Dimos7 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now