Markn1 Posted October 22, 2017 Share Posted October 22, 2017 (edited) يحفظ عند الذهاب إلى الملقم. إذا قمت بإعادة تشغيل المورد، فإنه لن حفظ 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 ) 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 ) --// addEventHandler("onResourceStart", 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) Edited October 22, 2017 by Markn1 1 Link to comment
#xi'MuhaMmeD,_) Posted October 22, 2017 Share Posted October 22, 2017 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) Link to comment
ميدوح Posted October 22, 2017 Share Posted October 22, 2017 local player = getLocalPlayer() local x, y, z = getElementPosition ( player ) local car1 = createVehicle ( 432, x, y, z + 10 ) local moto1 = createPed ( 113, x, y, z + 10 ) local air1 = createVehicle ( 577, x, y, z + 10 ) setElementData ( source, "car", car1,false) setElementData ( source, "moto", moto1,false) setElementData ( source, "air", air1,false) function onStartorLogin () acc = getPlayerAccount ( source ) ) if acc then setAccountData ( acc, "car", getElementData ( acc, "car" ) ) setAccountData ( acc, "moto", getElementData ( acc, "moto" ) ) setAccountData ( acc, "air", getElementData ( acc, "air" ) ) end end addEventHandler("onResourceStart", getRootElement(), onStartorLogin ) function onPlayerLogin (_, acc ) if (acc) then getAccountData ( acc, "car" ) getAccountData ( acc, "moto" ) getAccountData ( acc, "air" ) end end addEventHandler("onPlayerLogin", getRootElement(), onPlayerLogin ) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now