joao2235 Posted September 22, 2019 Share Posted September 22, 2019 Estou com um problema, é o seguinte: Estou usando o setElementData, ele funciona perfeitamente para estocar o valor determinado. Porém quando o "source", o player sai do server como por exemplo dá "reconnect" esse valor estocado não fica salvo. Alguém tem ideia de como consigo fazer para salvar ? Desde já agradeço! Link to comment
VictorScripting Posted September 22, 2019 Share Posted September 22, 2019 adicione isso em no final do script addEventHandler ( 'onPlayerQuit', root, function ( ) local acc = getPlayerAccount ( source ) saveAccountDataSono ( acc ) end ) addEventHandler ("onResourceStop",getResourceRootElement( getThisResource()),function() for index,players in ipairs(getElementsByType("player") do local acc = getPlayerAccount ( players ) saveAccountDataSono ( acc ) end Link to comment
DNL291 Posted September 23, 2019 Share Posted September 23, 2019 Faça o salvamento com a função setAccountData. - salvando os dados temporários na conta quando quita onPlayerQuit getElementData setAccountData - obtendo o valor quando loga e setando element-data: onPlayerLogin getAccountData seElementData 1 Link to comment
joao2235 Posted September 23, 2019 Author Share Posted September 23, 2019 13 hours ago, DNL291 said: Faça o salvamento com a função setAccountData. - salvando os dados temporários na conta quando quita onPlayerQuit getElementData setAccountData - obtendo o valor quando loga e setando element-data: onPlayerLogin getAccountData seElementData Fechado mestre, vou testar. Obrigado! Link to comment
joao2235 Posted September 23, 2019 Author Share Posted September 23, 2019 function SalvarDadosLogout (source) local ObterGalao = getElementData(source, "galao") local conta = getPlayerAccount (source) setAccountData(conta, "galao", ObterGalao) end addEventHandler("onPlayerQuit", root, SalvarDadosLogout) function DarDadosLogin (source) local conta = getPlayerAccount (source) local TemGalao = getAccountData(conta, "galao") setElementData(source, TemGalao) end addEventHandler("onPlayerLogin", root, DarDadosLogin) Porque isso não funcionou ? Link to comment
Other Languages Moderators Lord Henry Posted September 24, 2019 Other Languages Moderators Share Posted September 24, 2019 (edited) Não se usa source como parâmetro de função. function SalvarDadosLogout () local ObterGalao = getElementData (source, "galao") local conta = getPlayerAccount (source) setAccountData (conta, "galao", ObterGalao) end addEventHandler ("onPlayerQuit", root, SalvarDadosLogout) function DarDadosLogin (prevAcc, currAcc) local TemGalao = getAccountData (currAcc, "galao") setElementData (source, "galao", TemGalao) end addEventHandler ("onPlayerLogin", root, DarDadosLogin) Edited September 25, 2019 by Lord Henry Link to comment
DNL291 Posted September 25, 2019 Share Posted September 25, 2019 Corrigindo a setElementData: setElementData(source, "galao", TemGalao) 1 Link to comment
Other Languages Moderators Lord Henry Posted September 25, 2019 Other Languages Moderators Share Posted September 25, 2019 Corrigido, valeu 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