Baseplate Posted August 1, 2013 Share Posted August 1, 2013 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
Wei Posted August 1, 2013 Share Posted August 1, 2013 You didn't define driver and mechanic Link to comment
Baseplate Posted August 1, 2013 Author Share Posted August 1, 2013 Emm, how to fix it then? Link to comment
OGF Posted August 2, 2013 Share Posted August 2, 2013 triggerServerEvent("fixTheVehicle", localPlayer) Right there you only trigger the event and who is triggering the event, but you are not passing who the driver or mechanic is. https://wiki.multitheftauto.com/wiki/TriggerServerEvent 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