Jump to content

CarRespawn


Captain Cody

Recommended Posts

How would I make it so only cars from the resource Vehiclesave Respawn?

function spawnVehs() 
    for k, v in ipairs (getElementsByType("veh")) do 
        createVehicle(getElementData(v,"model"),getElementData(v,"posX"),getElementData(v,"posY"),getElementData(v,"posZ"),0,0,getElementData(v,"rotation")) 
    end 
    for k, v in ipairs (getElementsByType("vehicle")) do 
        toggleVehicleRespawn(v,true) 
        setVehicleIdleRespawnDelay(v,120000) 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(),spawnVehs) 
  
function respawnVeh() 
    setTimer(respawnVehicle,5000,1,source) 
end 
addEventHandler("onVehicleExplode",getRootElement(),respawnVeh 

And the adder\

\

function addNew(source,command) 
    if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)),aclGetGroup("Admin"))) then 
        if (isPedInVehicle(source)) then 
            local x,y,z = getElementPosition(getPedOccupiedVehicle(source)) 
            local model = getElementModel(getPedOccupiedVehicle(source)) 
            local rotX,rotY,rotZ = getVehicleRotation(getPedOccupiedVehicle(source)) 
            local file = xmlLoadFile("vehicles.map") 
            local veh = xmlCreateChild(file,"veh") 
            xmlNodeSetAttribute(veh,"model",model) 
            xmlNodeSetAttribute(veh,"posX",x) 
            xmlNodeSetAttribute(veh,"posY",y) 
            xmlNodeSetAttribute(veh,"posZ",z) 
            xmlNodeSetAttribute(veh,"rotation",rotZ) 
            xmlSaveFile(file) 
            xmlUnloadFile(file) 
            outputChatBox("*INFO* The vehicle has been successfully added and will be created in 5 seconds.",source,255,255,0) 
            outputDebugString(getPlayerName(source).." has mapped a "..getVehicleName(getPedOccupiedVehicle(source)).." in "..getElementZoneName(getPedOccupiedVehicle(source))..", "..getElementZoneName(getPedOccupiedVehicle(source),true)..".") 
            setTimer(function() createVehicle(model,x,y,z,0,0,rotZ) end,5000,1) 
        end 
    end 
end 
addCommandHandler("addc",addNew) 

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...