Jump to content

FixAllVehs


Eshtiz

Recommended Posts

There's a slight problem with this small script

After a global vehicle respawn & global vehicle repair they bug, engine breaks down and you cannot start the engine without an admin using /fixveh [id] on you, I've tried most things but I can't get it to work.

here's the /fixvehs script:

function fixAllVehicles(thePlayer, commandName) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
        local username = getPlayerName(thePlayer) 
        for key, value in ipairs(exports.pool:getPoolElementsByType("vehicle")) do 
            fixVehicle(value) 
            if (not getElementData(value, "Impounded")) then 
                exports['anticheat-system']:changeProtectedElementDataEx(value, "enginebroke", 0, false) 
                if armoredCars[ getElementModel( value ) ] then 
                    setVehicleDamageProof(value, true) 
                else 
                setVehicleDamageProof(value, false) 
                end 
            end 
        end 
        outputChatBox("All vehicles repaired by Admin " .. username .. ".") 
    end 
end 
addCommandHandler("fixvehs", fixAllVehicles) 

here's the specific vehicle repair by ID/name, might help to fix the /fixvehs

function fixPlayerVehicle(thePlayer, commandName, target) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
        if not (target) then 
            outputChatBox("SYNTAX: /" .. commandName .. " [Partial Player Nick]", thePlayer, 255, 194, 14) 
        else 
            local username = getPlayerName(thePlayer) 
            local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, target) 
             
            if targetPlayer then 
                local logged = getElementData(targetPlayer, "loggedin") 
                if (logged==0) then 
                    outputChatBox("Player is not logged in.", thePlayer, 255, 0, 0) 
                else 
                    local veh = getPedOccupiedVehicle(targetPlayer) 
                    if (veh) then 
                        fixVehicle(veh) 
                        if (getElementData(veh, "Impounded") == 0) then 
                            exports['anticheat-system']:changeProtectedElementDataEx(veh, "enginebroke", 0, false) 
                            if armoredCars[ getElementModel( veh ) ] then 
                                setVehicleDamageProof(veh, true) 
                            else 
                                setVehicleDamageProof(veh, false) 
                            end 
                        end 
                        outputChatBox("You repaired " .. targetPlayerName .. "'s vehicle.", thePlayer) 
                        outputChatBox("Your vehicle was repaired by admin " .. username .. ".", targetPlayer) 
                    else 
                        outputChatBox("That player is not in a vehicle.", thePlayer, 255, 0, 0) 
                    end 
                end 
            end 
        end 
    end 
end 
addCommandHandler("fixveh", fixPlayerVehicle, false, false) 

EDIT: added wrong script (fuel), changed it to repair.

EDIT: I figured out the real problem, it's in /fixvehs, it only repairs the vehicle's appearance but doesn't repair the engine so it's not possible to start it.

Link to comment
function fixAllVehicles(thePlayer, commandName) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
        local username = getPlayerName(thePlayer) 
        for key, value in ipairs(exports.pool:getPoolElementsByType("vehicle")) do 
            fixVehicle(value) 
            setVehicleEngineState(value, true) 
            exports['anticheat-system']:changeProtectedElementDataEx(value, "enginebroke", 0, false) 
            exports['anticheat-system']:changeProtectedElementDataEx(value, "engine", 0, false) 
                if armoredCars[ getElementModel( value ) ] then 
                    setVehicleDamageProof(value, true) 
                else 
                setVehicleDamageProof(value, false) 
            end 
        end 
        outputChatBox("All vehicles repaired by Admin " .. username .. ".") 
    end 
end 
addCommandHandler("fixvehs", fixAllVehicles) 

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