Jimmy Posted August 11, 2016 Share Posted August 11, 2016 ERROR VEHICLE: [22:44:35] ERROR: [systems]\vehicle-system\s_vehicle_system.lua:43: cannot resume dead coroutine [string "?"] [DUP x1235] s_vehicle_system mysql = exports.mysql local null = mysql_null() local toLoad = { } local threads = { } function saveDescriptions(savedDescriptions, theVehicle) for i, v in ipairs(savedDescriptions) do exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, "description:"..i, v) end mysql:query_free("UPDATE vehicles SET vehicledescription='" .. mysql:escape_string(toJSON(savedDescriptions)) .. "' WHERE id='" .. mysql:escape_string(getElementData(theVehicle,"dbid")) .. "' LIMIT 1") end addEvent("saveDescriptions", true) addEventHandler("saveDescriptions", getRootElement(), saveDescriptions) function loadAllVehicles(res) local players = exports.pool:getPoolElementsByType("player") for key, value in ipairs(players) do exports['anticheat-system']:changeProtectedElementDataEx(value, "realinvehicle", 0, false) end local result = mysql:query("SELECT id FROM `vehicles` ORDER BY `id` ASC") if result then while true do local row = mysql:fetch_assoc(result) if not row then break end toLoad[tonumber(row["id"])] = true end mysql:free_result(result) for id in pairs( toLoad ) do local co = coroutine.create(loadOneVehicle) coroutine.resume(co, id, true) table.insert(threads, co) end setTimer(resume, 1000, 4) else outputDebugString( "loadAllVehicles failed" ) end end addEventHandler("onResourceStart", getResourceRootElement(), loadAllVehicles) function resume() for key, value in ipairs(threads) do coroutine.resume(value) end end function reloadVehicle(id) local theVehicle = exports.pool:getElement("vehicle", tonumber(id)) if (theVehicle) then removeSafe(tonumber(id)) exports['savevehicle-system']:saveVehicle(theVehicle) destroyElement(theVehicle) end loadOneVehicle(id, false) return true end function loadOneVehicle(id, hasCoroutine) if (hasCoroutine==nil) then hasCoroutine = false end local row = mysql:query_fetch_assoc("SELECT * FROM vehicles WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" ) if row then if (hasCoroutine) then coroutine.yield() end for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(row[k]) or row[k] end end local var1, var2 = row.variant1, row.variant2 if not isValidVariant(row.model, var1, var2) then var1, var2 = getRandomVariant(row.model) mysql:query_free("UPDATE vehicles SET variant1 = " .. var1 .. ", variant2 = " .. var2 .. " WHERE id='" .. mysql:escape_string(row.id) .. "'") end local veh = createVehicle(row.model, row.currx, row.curry, row.currz, row.currrx, row.currry, row.currrz, row.plate, false, var1, var2) if veh then exports['anticheat-system']:changeProtectedElementDataEx(veh, "dbid", row.id) exports.pool:allocateElement(veh, row.id) local color1 = fromJSON(row.color1) local color2 = fromJSON(row.color2) local color3 = fromJSON(row.color3) local color4 = fromJSON(row.color4) setVehicleColor(veh, color1[1], color1[2], color1[3], color2[1], color2[2], color2[3], color3[1], color3[2], color3[3], color4[1], color4[2], color4[3]) if row.paintjob ~= 0 then setVehiclePaintjob(veh, row.paintjob) end if (armoredCars[row.model]) then setVehicleDamageProof(veh, true) end local upgrades = fromJSON(row["upgrades"]) for slot, upgrade in ipairs(upgrades) do if upgrade and tonumber(upgrade) > 0 then addVehicleUpgrade(veh, upgrade) end end local panelStates = fromJSON(row["panelStates"]) for panel, state in ipairs(panelStates) do setVehiclePanelState(veh, panel-1 , tonumber(state) or 0) end local doorStates = fromJSON(row["doorStates"]) for door, state in ipairs(panelStates) do setVehicleDoorState(veh, door-1, tonumber(state) or 0) end local headlightColors = fromJSON(row["headlights"]) if headlightColors then setVehicleHeadLightColor ( veh, headlightColors[1], headlightColors[2], headlightColors[3]) end exports['anticheat-system']:changeProtectedElementDataEx(veh, "headlightcolors", headlightColors, true) local wheelStates = fromJSON(row["wheelStates"]) setVehicleWheelStates(veh, tonumber(wheelStates[1]) , tonumber(wheelStates[2]) , tonumber( wheelStates[3]) , tonumber(wheelStates[4]) ) setVehicleLocked(veh, row.owner ~= -2 and row.locked == 1) setVehicleSirensOn(veh, row.sirens == 1) exports['vehicle-interiors']:add( veh ) setVehicleRespawnPosition(veh, row.x, row.y, row.z, row.rotx, row.roty, row.rotz) exports['anticheat-system']:changeProtectedElementDataEx(veh, "respawnposition", {row.x, row.y, row.z, row.rotx, row.roty, row.rotz}, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "asigurare", row.asigurare) exports['anticheat-system']:changeProtectedElementDataEx(veh, "fuel", row.fuel, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldx", row.currx, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldy", row.curry, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldz", row.currz, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "faction", row.faction) exports['anticheat-system']:changeProtectedElementDataEx(veh, "owner", tonumber(row.owner)) exports['anticheat-system']:changeProtectedElementDataEx(veh, "vehicle:windowstat", 0, true) exports['anticheat-system']:changeProtectedElementDataEx(veh, "Impounded", tonumber(row.Impounded)) if tonumber(row.Impounded) > 0 then setVehicleDamageProof(veh, true) end setElementDimension(veh, row.currdimension) setElementInterior(veh, row.currinterior) exports['anticheat-system']:changeProtectedElementDataEx(veh, "dimension", row.dimension, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "interior", row.interior, false) setVehicleOverrideLights(veh, row.lights == 0 and 1 or row.lights ) if row.hp <= 350 then setElementHealth(veh, 300) setVehicleDamageProof(veh, true) setVehicleEngineState(veh, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", 0, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "enginebroke", 1, false) else setElementHealth(veh, row.hp) setVehicleEngineState(veh, row.engine == 1) exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", row.engine, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "enginebroke", 0, false) end setVehicleFuelTankExplodable(veh, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "handbrake", row.handbrake, false) if row.handbrake > 0 then setElementFrozen(veh, true) end local hasInterior, interior = exports['vehicle-interiors']:add( veh ) if hasInterior and row.safepositionX and row.safepositionY and row.safepositionZ and row.safepositionRZ then addSafe( row.id, row.safepositionX, row.safepositionY, row.safepositionZ, row.safepositionRZ, interior ) end if row.tintedwindows == 1 then exports['anticheat-system']:changeProtectedElementDataEx(veh, "tinted", true, true) end exports['anticheat-system']:changeProtectedElementDataEx(veh, "odometer", tonumber(row.odometer), false) local vehicledescriptions = fromJSON(row["vehicledescription"]) for i, v in ipairs(vehicledescriptions) do exports['anticheat-system']:changeProtectedElementDataEx(veh, "description:"..i, v or "") end end end end function vehicleExploded() local job = tonumber(getElementData(source, "job")) if not job or job<=0 then setTimer(respawnVehicle, 60000, 1, source) end end addEventHandler("onVehicleExplode", getRootElement(), vehicleExploded) function vehicleRespawn(exploded) local id = tonumber(getElementData(source, "dbid")) local faction = tonumber(getElementData(source, "faction")) local job = tonumber(getElementData(source, "job")) local owner = tonumber(getElementData(source, "owner")) local windowstat = tonumber(getElementData(source, "vehicle:windowstat")) if (job>0) then toggleVehicleRespawn(source, true) setVehicleRespawnDelay(source, 60000) setVehicleIdleRespawnDelay(source, 15 * 60000) setElementFrozen(source, true) exports['anticheat-system']:changeProtectedElementDataEx(source, "handbrake", 1, false) end local vehid = getElementModel(source) if (armoredCars[tonumber(vehid)]) then setVehicleDamageProof(source, true) else setVehicleDamageProof(source, false) end setVehicleFuelTankExplodable(source, false) setVehicleEngineState(source, false) setVehicleLandingGearDown(source, true) exports['anticheat-system']:changeProtectedElementDataEx(source, "enginebroke", 0, false) exports['anticheat-system']:changeProtectedElementDataEx(source, "dbid", id) exports['anticheat-system']:changeProtectedElementDataEx(source, "fuel", 100) exports['anticheat-system']:changeProtectedElementDataEx(source, "engine", 0, false) exports['anticheat-system']:changeProtectedElementDataEx(source, "vehicle:windowstat", windowstat, false) local x, y, z = getElementPosition(source) exports['anticheat-system']:changeProtectedElementDataEx(source, "oldx", x, false) exports['anticheat-system']:changeProtectedElementDataEx(source, "oldy", y, false) exports['anticheat-system']:changeProtectedElementDataEx(source, "oldz", z, false) exports['anticheat-system']:changeProtectedElementDataEx(source, "faction", faction) exports['anticheat-system']:changeProtectedElementDataEx(source, "owner", owner, false) setVehicleOverrideLights(source, 1) setElementFrozen(source, false) setVehicleSirensOn(source, false) setVehicleLightState(source, 0, 0) setVehicleLightState(source, 1, 0) local dimension = getElementDimension(source) local interior = getElementInterior(source) setElementDimension(source, dimension) setElementInterior(source, interior) if owner == -2 then setVehicleLocked(source, false) setElementFrozen(source, true) exports['anticheat-system']:changeProtectedElementDataEx(source, "handbrake", 1, false) end setElementFrozen(source, getElementData(source, "handbrake") == 1) end addEventHandler("onVehicleRespawn", getResourceRootElement(), vehicleRespawn) function setEngineStatusOnEnter(thePlayer, seat) if seat == 0 then local engine = getElementData(source, "engine") local model = getElementModel(source) if not (enginelessVehicle[model]) then if (engine==0) then toggleControl(thePlayer, 'brake_reverse', false) setVehicleEngineState(source, false) else toggleControl(thePlayer, 'brake_reverse', true) setVehicleEngineState(source, true) end else toggleControl(thePlayer, 'brake_reverse', true) setVehicleEngineState(source, true) exports['anticheat-system']:changeProtectedElementDataEx(source, "engine", 1, false) end end triggerEvent("sendCurrentInventory", thePlayer, source) end addEventHandler("onVehicleEnter", getRootElement(), setEngineStatusOnEnter) function vehicleExit(thePlayer, seat) if (isElement(thePlayer)) then Link to comment
Jurand Posted August 11, 2016 Share Posted August 11, 2016 maybe i'm wrong but i saw on wiki.mta that this function is no longer needed, beacuse it is included to every script + don't use mysql module, replace it to db functions ( dbConnect, dbExec, dbQuery ). 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