addEventHandler("onPlayerLogin",root,function (_,curr)
local plr = source
setTimer(function ()
for key, value in pairs(getAllAccountData(curr)) do
if string.find(key,"data:") then
setElementData(plr,key,fromJSON(value) or value )
end
local account = getPlayerAccount(source)
local ranga = getAccountData(account, "ranga")
if getAccountData(account,"ranga") then
setAccountData(account, "ranga", ranga)
setElementData(source, "ranga", ranga)
end
end
end,6700,1)
end)
addEventHandler("onPlayerQuit",root,function ()
if getPlayerAccount(source) and ( not isGuestAccount( getPlayerAccount(source) ) ) then
local account = getPlayerAccount(source)
for key, value in pairs(getAllElementData( source )) do
if string.find(key,"data:") then
if type(value) == "table" then
setAccountData(account,key,toJSON( value ))
else
setAccountData(account,key,value)
end
local ranga = getElementData(source, "ranga")
if getElementData(source,"ranga") then
setAccountData(account, "ranga", ranga)
end
end Takie cos stworzylem jest to mega chaotyczne ale nie wiem jak lepiej zrobic xD No i oczywiscie nie dzia?a