Jump to content

Helping


Baseplate

Recommended Posts

s.lua

  
function fixThisVehicle(driver, mechanic) 
    if (getPedOccupiedVehicleSeat(driver) == 0) and (getTeamName(getPlayerTeam(mechanic)) == "Mechanic") then 
        if (getPedOccupiedVehicleSeat(mechanic) > 1) then 
            outputChatBox("You should enter near the driver to fix the vehicle!", mechanic, 255, 0, 0) 
        end 
        if (getPedOccupiedVehicleSeat(mechanic) == 1) then 
            if (getElementHealth(getPedOccupiedVehicle(driver)) > 999) then 
                outputChatBox("You don't need to repair this vehicle", mechanic, 255, 0, 0) 
            elseif (getElementHealth(getPedOccupiedVehicle(driver)) < 1000) then 
                local price = math.floor(1000 - getElementHealth(getPedOccupiedVehicle(driver))) 
            if (getPlayerMoney(driver) < price) then 
                outputChatBox("The driver have not enough money!", mechanic, 255, 0, 0) 
            else 
                outputChatBox("Your vehicle has been repaired for $"..price.." by "..getPlayerName(mechanic), driver, 0, 200, 0) 
                outputChatBox("You repaired "..getPlayerName(driver).." for $"..price, mechanic, 0, 255, 0) 
                fixVehicle(getPedOccupiedVehicle(driver)) 
                takePlayerMoney(driver, price) 
                givePlayerMoney(mechanic, price) 
                for k, v in ipairs({"accelerate", "enter_exit", "handbrake"}) do 
                    toggleControl(driver,v,false) 
                end 
                setControlState(driver, "handbrake", true) 
            end 
        end 
    end 
end 
end 
addEvent("fixTheVehicle", true) 
addEventHandler("fixTheVehicle", root, fixThisVehicle) 

c.lua

addEventHandler("onClientGUIClick", root, 
function() 
if (source == yesMech) then 
triggerServerEvent("fixTheVehicle", localPlayer) 
guiSetVisible(mechPanel, false) 
showCursor(false) 
elseif (source == noMech) then 
guiSetVisible(mechPanel, false) 
showCursor(false) 
end 
end 
) 

This is my current code, when I press on the "yesMech" button nothing happens.

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