Jump to content

[Problem]


gghvcffcv

Recommended Posts

I got an error with this, If mechanic is in Driver Seat he wins money and fix the car.

only fix car and win money if he is in Passenger seat and there's another player in driver seat

local allowedTeams = {  
["Mechanics"] = true, 
["Mechanic"] = true, 
["Staff"] = true, 
["Admins"] = true, 
} 
  
function fix () 
car = getPedOccupiedVehicle(source) 
if allowedTeams[getTeamName(getPlayerTeam(source))] and getElementHealth(car) < 999 then 
price = 1001 - getElementHealth(car)  
givePlayerMoney(source, price*20) 
fixVehicle(car)  
outputChatBox("You have fixed this car", source, 0, 255, 0) 
end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), fix) 

Link to comment

Try this:

local allowedTeams = { 
["Mechanics"] = true, 
["Mechanic"] = true, 
["Staff"] = true, 
["Admins"] = true, 
} 
  
function fix (theVehicle, seat, jacked) 
    if seat ~= 0 then 
        local driver = getVehicleController(theVehicle) 
        if (getElementType(driver) == "player") then 
            if allowedTeams[getTeamName(getPlayerTeam(source))] and getElementHealth(theVehicle) < 999 then 
                local price = 1001 - getElementHealth(theVehicle) 
                givePlayerMoney(source, price*20) 
                fixVehicle(theVehicle) 
                outputChatBox("You have fixed this car", source, 0, 255, 0) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), fix) 

Link to comment
Try this:
local allowedTeams = { 
["Mechanics"] = true, 
["Mechanic"] = true, 
["Staff"] = true, 
["Admins"] = true, 
} 
  
function fix (theVehicle, seat, jacked) 
    if seat ~= 0 then 
        local driver = getVehicleController(theVehicle) 
        if (getElementType(driver) == "player") then 
            if allowedTeams[getTeamName(getPlayerTeam(source))] and getElementHealth(theVehicle) < 999 then 
                local price = 1001 - getElementHealth(theVehicle) 
                givePlayerMoney(source, price*20) 
  
  
Thanks you 
                fixVehicle(theVehicle) 
                outputChatBox("You have fixed this car", source, 0, 255, 0) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), 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...