Jump to content

حفظ (مساعدة)


Markn1

Recommended Posts

يحفظ عند الذهاب إلى الملقم. إذا قمت بإعادة تشغيل المورد، فإنه لن حفظ

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 by Markn1
  • Haha 1
Link to comment
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...