Jump to content

Mechanic


xXMADEXx

Recommended Posts

Hey MTA community, i have made this mechanic script, but it keeps saying "This vehicle has no driver."... no idea why.

function fix (player) 
    local car = getPedOccupiedVehicle(player) 
    local driver = getVehicleOccupant (player) 
    local equation = 1500 - getElementHealth(car) 
    if (getElementData(player,"Job")=="Mechanic") then 
        if (getPedOccupiedVehicleSeat(player)==0) then 
            outputChatBox("You cannot fix a vehicle, from the driver seat.",player,255,0,0) 
        else 
            if (driver) then 
                if (getPlayerMoney(driver) > equation ) then 
                    takePlayerMoney(driver,equation) 
                    givePlayerMoney(player,equation) 
                    triggerClientEvent(driver,"message:addMessage",driver,"Mechanic: "..getPlayerName(player).." has fixed your vehicle for $"..equation.."!") 
                    triggerClientEvent(player,"message:addMessage",player,"Mechanic: You have fixed "..getPlayerName(driver).."'s vehicle for "..equation.."!") 
                else 
                    outputChatBox("The driver dosn't have $"..equation.." to repair the vehicle!",player,255,0,0) 
                    outputChatBox("You don't have "..equation.." to repair this vehicle.",driver,255,0,0) 
                end 
            else 
                outputChatBox("This vehicle has no driver.",player,255,0,0) 
            end 
        end 
    end 
end 
addCommandHandler('fix',fix) 

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