local config = {
saveInterval = 6 * 60,
minSaveInterval = 4 * 60,
maxSaveInterval = 8 * 60,
storage = 16046
}
function saveRepeat(cid)
if isPlayer(cid) then
doSavePlayerAndHouse(cid)
setPlayerStorageValue(cid, config.storage, addEvent(saveRepeat, config.saveInterval*1000, cid))
end
return true
end
function onLogin(cid)
if (getPlayerAccount(getPlayerByName(name)) ~= 1) or (getPlayerAccount(getPlayerByName(name)) ~= 2) then
setPlayerStorageValue(cid, config.storage, addEvent(saveRepeat, math.random(config.minSaveInterval, config.maxSaveInterval) * 1000, cid))
end
return true
end
function onLogout(cid)
doSaveHouse({getHouseByPlayerGUID(getPlayerGUID(cid))})
stopEvent(getPlayerStorageValue(cid, config.storage))
return true
end