local saveableData = { ["car"] = true, ["moto"] = true, ["air"] = true }
function onStartorLogin (_,acc)
setElementData ( source, "car", getAccountData ( acc, "car" ) or false )
setElementData ( source, "moto", getAccountData ( acc, "moto" ) or false )
setElementData ( source, "air", getAccountData ( acc, "air" ) or false )
end
addEventHandler("onPlayerLogin", getRootElement(), onStartorLogin )
addEventHandler("onResourceStart", getRootElement(), onStartorLogin )
function onResRestrt (_,acc)
setAccountData ( source, "car", getElementData ( acc, "car" ) or false )
setAccountData ( source, "moto", getElementData ( acc, "moto" ) or false )
setAccountData ( source, "air", getElementData ( acc, "air" ) or false )
end
addEventHandler("onResourceStop", getRootElement(), onResRestrt )
function outputChange(dataName,oldValue)
if getElementType(source) == "player" then
if saveableData[dataName] then
setAccountData ( getPlayerAccount ( source ), dataName, getElementData ( source, dataName ) )
end
end
end
addEventHandler("onElementDataChange",getRootElement(),outputChange)