Hi everyone! i edited my "login", everything work fine, saving datas but, i made a "serial protect" to acccount. When you register, it set your serial, when you login, it check is this your serial if not the script kick you.
So the problem is, when i trying to login to another account which is protected by "serial protect", the server kick the player who tried to login to another account, but reseting the datas i mean not saving your bank balance, or rcPoints, adminlevel etc..
Here is the login part:
addEventHandler("onPlayerLogin", getRootElement(),function(_, account)
local serial = getPlayerSerial(source)
if getAccountData(getPlayerAccount(source),"acc.protect") ~= serial then
kickPlayer(source,"Server","Not your account!")
else
triggerEvent("loadAccount",source,account)
setElementData(source,"loggedin",true)
exports["rc_notification"]:notification("You successfully logged in!",source,"info")
end
end)
the triggerEvent:
addEvent("accountBetoltese", true)
addEventHandler("loadAccount",root,function (account)
local playerX = getAccountData(account,"acc.pos_X")
local playerY = getAccountData(account,"acc.pos_Y")
local playerZ = getAccountData(account,"acc.pos_Z")
local rotacio = getAccountData(account,"acc.Rot" or 0)
local interior = getAccountData(account,"acc.interior" or 0)
local dimenzio = getAccountData(account,"acc.dimension" or 0)
local kinezet = getAccountData(account,"acc.skinID" or 0)
local elet = getAccountData(account,"acc.health" or 0)
local armor = getAccountData(account,"acc.armor" or 0)
local bank = getAccountData(account,"acc.bank" or 0)
local admin = getAccountData(account,"acc.admin" or 0)
local rcPoints = getAccountData(account,"acc.rcPoints" or 0)
local fegyverek = getAccountData(account,"acc.Weapons")
local teamname = getAccountData(account,"acc.squad")
local money = getAccountData(account,"acc.money")
local team = teamname and getTeamFromName(teamname) or nil
if playerX or PlayerY or playerZ then spawnPlayer(source, playerX, playerY, playerZ, rotacio, kinezet, interior, dimenzio, team) end
if elet then setElementHealth(source, elet) end
if money then setElementData(source,"acc.money",money) end
if rcPoints then setElementData(source,"acc.rcPoints",rcPoints) end
if armor then setPedArmor(source, armor) end
if bank then setElementData(source,"acc.bank",bank) end
if admin then setElementData(source,"acc.admin",admin) end
if (fegyverek) and not (isPedDead(source)) then
takeAllWeapons(source)
for weapon, ammo in pairs(fromJSON(fegyverek)) do
giveWeapon(source, weapon, ammo, true)
end
end
setCameraTarget(source, source)
end)
I dont rlly know what can be the problem. Anyway, here is the onPlayerQuit, for saving the datas:
addEvent("accountMentese", true)
addEventHandler("accountMentese",root,function (account)
local accountName = getAccountName(account)
local x,y,z = getElementPosition (source)
local _, _, rotacio = getElementRotation(source)
local interior = getElementInterior(source)
local dimenzio = getElementDimension(source)
local team = getPlayerTeam(source)
local kinezet = getElementModel(source)
local elet = getElementHealth(source)
local armor = getPedArmor(source)
local bank = getElementData(source,"acc.bank")
local admin = getElementData(source,"acc.admin")
local rcPoints = getElementData(source,"acc.rcPoints")
local money = exports["rc_core"]:getMoney(source)
local finalteam = team and getTeamName(team) or nil
local fegyverek = getAllPedWeapon(source)
setAccountData(account,"acc.bank",bank)
setAccountData(account,"acc.admin",admin)
setAccountData(account,"acc.rcPoints",rcPoints)
setAccountData(account,"acc.Rot",rotacio)
setAccountData(account,"acc.money",money)
setAccountData(account,"acc.dimension",dimenzio)
setAccountData(account,"acc.interior", interior)
setAccountData(account,"acc.squad",finalteam)
setAccountData(account,"acc.skinID",kinezet)
setAccountData(account,"acc.health",elet)
setAccountData(account,"acc.armor",armor)
setAccountData(account,"acc.pos_X", x)
setAccountData(account,"acc.pos_Y", y)
setAccountData(account,"acc.pos_Z", z)
if (fegyverek) and not (isPedDead(source)) then
setAccountData(account, "acc.Weapons", toJSON(fegyverek))
end
end)
onQuit..
addEventHandler("onPlayerQuit",root,function ()
local account = getPlayerAccount(source)
if (account) and not (isGuestAccount(account)) then
triggerEvent("accountMentese", source, account)
end
end)
Thanks any help!