Jump to content

[help] repair vehicle


Recommended Posts

I made this script for when the player clicks the button GUIEditor.button [1] your vehicle is repaired What did this wrong?

I used AddEventHandler inside the window gui

        addEventHandler('onClientGUIClick',GUIEditor.button[1],fix,false) 

and out the window I used:

function fix ( thePlayer, commandName) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        local theVehicle = getPedOccupiedVehicle ( thePlayer) 
        local succes = fixVehicle ( theVehicle ) 
        if ( succes ) then 
            outputChatBox (" Vehicle fixed. ", thePlayer ) 
        else 
            outputChatBox ( "Failed to fix your vehicle.", thePlayer) 
        end 
    else 
        outputChatBox ( "You must be in a vehicle!", thePlayer ) 
    end 
end 

What did this wrong? why is not repairing the vehicle?

Link to comment
function fix ( ) 
    if ( isPedInVehicle ( localPlayer ) ) then 
        local theVehicle = getPedOccupiedVehicle ( localPlayer) 
        local succes = fixVehicle ( theVehicle ) 
        if ( succes ) then 
            outputChatBox (" Vehicle fixed. " ) 
        else 
            outputChatBox ( "Failed to fix your vehicle.") 
        end 
    else 
        outputChatBox ( "You must be in a vehicle!" ) 
    end 
end 

Link to comment

Well as I said I never used and do not know how most tried this:

local lastTick = 0 
local toWait = 60000 
 addEventHandler ( "onClientGUIClick", guiRoot, 
    function ( ) 
        if ( source == GUIEditor.button[2] ) then 
            end 
            if ( getTickCount ( ) - lastTick >= toWait ) then 
                    lastTick = getTickCount ( ) 
            else 
                outputChatBox ( "You must wait 60 seconds to use it again!", 255, 0, 0 ) 
            end 
        end 
    end             
) 

I want to put to use can only GUIEditor.button [2] every 1 minute What did this wrong?

Link to comment
addEventHandler ( "onClientGUIClick", root, 
    function ( ) 
        if ( source == GUIEditor.button[2] ) then 
            local car = getPedOccupiedVehicle ( localPlayer ) 
            if ( car ) then 
                fixVehicle ( car ) 
                guiSetEnabled ( source, false )  
                setTimer ( function  ( element ) 
                    guiSetEnabled ( element, true ) 
                end, 60000, 1, source ) 
            end 
        end 
    end 
) 

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