After this code that is working:
function onPlayerQuit()
local playerAccount = getPlayerAccount(source)
if (playerAccount) then
local playerMoney = getPlayerMoney(source)
setAccountData(playerAccount, "player.money", playerMoney)
end
end
addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit)
function onPlayerLogin()
local playerAccount = getPlayerAccount(source)
if (playerAccount) then
local playerMoney = getAccountData(playerAccount, "player.money")
if (playerMoney) then
setPlayerMoney(source, playerMoney)
end
end
end
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin)
I've tryed this:
function onPlayerQuit()
local playerAccount = getPlayerAccount(source)
if (playerAccount) then
local Score = getScore(source)
setAccountData(playerAccount, "player.score", Score)
end
end
addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit)
function onPlayerLogin()
local playerAccount = getPlayerAccount(source)
if (playerAccount) then
local Score = getAccountData(playerAccount, "player.score")
if (playerMoney) then
setScore(source, Score)
end
end
end
addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin))
I have also tryed whyt PlayerScore instead of just score but none worked, the problem is that I don't get where is the problem or what I've done wrong....
The codes were written in the gamemode.lua and not as a resource.