to IIYAMA, can you just write where's the problem? why single resource is working, but integrating the code to my main .lua file gives no result?
edited: okay, i got it. when main resource starts, vehicles need time to spawn and the "vehicle" element table is just EMPTY, so the fucntions apply to no elements. setting timer solves this problem.
function onStart()
-- car spawn
setTimer (function()
for i, v in ipairs (getElementsByType("vehicle")) do
toggleVehicleRespawn(v, true)
setVehicleRespawnDelay(v, 5000)
setVehicleIdleRespawnDelay(v, 5000)
end
end, 1000,1)
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStart)