function saveData(p)
if not source and p then source = p; end
local a = getPlayerAccount(source);
if a then
if not isGuestAccount(a) then
setAccountData(a, "user.money", getPlayerMoney(source));
setAccountData(a, "user.skin", getPedSkin(source));
setAccountData(a, "user.health", getElementHealth(source));
setAccountData(a, "user.armor", getPedArmor(source));
local x,y,z = getElementPosition(source);
setAccountData(a, "user.pos", toJSON({x,y,z,getElementInterior(source),getElementDimension(source)}));
local rx, ry, rz = getElementRotation(source);
setAccountData(a, "user.rot", toJSON({rx,ry,rz}));
local stats = {};
for i=69,79 do
stats[i] = getPedStat(source,i);
end
setAccountData(a, 'user.stats', toJSON(stats));
end
end
end
addEventHandler("onPlayerQuit",getRootElement(),saveData)
addEventHandler("onPlayerLogout",getRootElement(),saveData)
addEventHandler("onPlayerWasted",getRootElement(),saveData)
function playerLogin (thePreviousAccount, theCurrentAccount, autoLogin)
local a = getPlayerAccount(source);
if not isGuestAccount(a) then
local pos = fromJSON(getAccountData(theCurrentAccount,"user.pos")) or {};
if pos[1] and pos[2] and pos[3] then
local money = getAccountData(theCurrentAccount,"user.money");
local health = getAccountData(theCurrentAccount,"user.health");
local armor = getAccountData(theCurrentAccount,"user.armor");
local skin = getAccountData(theCurrentAccount,"user.skin");
local rx,ry,rz = fromJSON(getAccountData(theCurrentAccount,"user.rot"));
if not rx then rx = 0; end;
if not ry then ry = 0; end;
if not rz then rz = 0; end;
local stats = fromJSON(getAccountData(theCurrentAccount,"user.stats"));
spawnPlayer(source,pos[1],pos[2],pos[3],0,skin,pos[4],pos[5]);
--setElementRotation(source,tonumber(rx),tonumber(ry),tonumber(rz));
setElementRotation(source,0,0,0);
setElementHealth(source,health);
setPedArmor(source,armor);
setPlayerMoney(source,money);
setElementFrozen(source,false);
setElementAlpha(source,255)
for i=69,79 do
setPedStat(source,i,tonumber(stats[tostring(i)]));
end
else
FirstTimePlaying();
end
setCameraTarget(source,source);
fadeCamera(source,true,2);
end
end
addEventHandler ("onPlayerLogin", getRootElement(), playerLogin)
function FirstTimePlaying()
local PedSkins = {78,79};
setPlayerMoney(source,2500);
giveWeapon(source,math.random(22,23),250);
giveWeapon(source,25,25);
end
function saveWeaponData(p)
if not source and p then source = p; end
local a = getPlayerAccount(source);
if not isGuestAccount(a) then
for i=0,11 do
setAccountData(a, "weapon."..i,toJSON({getPedWeapon(source,i),getPedTotalAmmo(source,i)}));
end
end
end
addEventHandler("onPlayerQuit",getRootElement(),saveWeaponData)
addEventHandler("onPlayerWasted",getRootElement(),saveWeaponData)
addEventHandler("onPlayerLogout",getRootElement(),saveWeaponData)
function loadWeaponData(p)
if not source and p then source = p; end
local a = getPlayerAccount(source);
if not isGuestAccount(a) then
for i=0,11 do
local w = fromJSON(getAccountData(a, "weapon."..i, getPedWeapon(source,i)));
giveWeapon(source,w[1],w[2]);
end
end
end
addEventHandler("onPlayerSpawn",getRootElement(),loadWeaponData)
Здравствуйте, кто может помочь с такой проблемой, после смерти слетает скин, но система сохранение аккаунтов стоит, пробовал много разных способов ничего не помогло.
Прошу кто может помогите!