kam_ Posted March 2, 2021 Share Posted March 2, 2021 saveitens = { [1] = {"Whiskey"}, [2] = {"Agua"}, [3] = {"Chocolate"}, [4] = {"Coca-Cola"}, } function Save_Itens(conta) if conta then local source = getAccountPlayer(conta) if isElement(source) then for i, saveitens in ipairs(saveitens) do local bank = getElementData(source, saveitens[1]) or 0 setAccountData(conta, saveitens[1], tonumber(bank)) end end end end addEventHandler("onPlayerLogin", root, function(_,acc) setTimer(Load_Itens,100,1,acc) end ) function Start_Itens(res) if res == getThisResource() then for i, player in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then Load_Itens(acc) end end end end addEventHandler("onResourceStart", getRootElement(), Start_Itens) function Stop_Itens(res) if res == getThisResource() then for i, player in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then Save_Itens(acc) end end end end addEventHandler("onResourceStop", getRootElement(), Stop_Itens) function Quit_Itens(quitType) local acc = getPlayerAccount(source) if not (isGuestAccount(acc)) then if acc then Save_Itens(acc) end end end addEventHandler("onPlayerQuit", getRootElement(), Quit_Itens) function Load_Itens(conta) if not (isGuestAccount (conta)) then if (conta) then local source = getAccountPlayer(conta) if isElement(source) then for i, saveitens in ipairs(saveitens) do local bank = getAccountData(conta,saveitens[1]) or 0 setElementData(source, saveitens[1], tonumber(bank)) end end end end end pra salvar elementData por tabela, está certo? 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