Jump to content

Hotkey help


Vaux42

Recommended Posts

I want to repair the vehicle on the press of "F7"

What's wrong with my code?

function bindTheKeys 
    bindKey("F7","down",fix) 
end 
addEventHandler("onClientResourceStart", resourceRoot, bindTheKeys) 
function fix 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    fixVehicle(theVehicle) 
end 
addEvent("fix",true) 
addEventHandler("fix",resourceRoot,fix) 

Link to comment

Client

  
  
bindKey( 'F7', 'down', 
    function( ) 
        if isPedInVehicle( localPlayer ) then 
            local uVehicle = getPedOccupiedVehicle( localPlayer ) 
            if uVehicle then 
                fixVehicle( uVehicle ) 
            end  
        end  
    end 
)     

You not define function.

Syntax error

  
function bindTheKeys -- You forgot ( ) 
    bindKey("F7","down",fix) 
end 
addEventHandler("onClientResourceStart", resourceRoot, bindTheKeys) 
function fix -- You forgot ( ) 
    local theVehicle = getPedOccupiedVehicle( localPlayer ) 
    fixVehicle(theVehicle) 
end 
addEvent("fix",true) 
addEventHandler("fix",resourceRoot,fix) 
  

Edited by Guest
Link to comment
  
function fix () 
        if isPedInVehicle( localPlayer ) then 
            local uVehicle = getPedOccupiedVehicle( localPlayer ) 
            if uVehicle then 
            fixVehicle( uVehicle ) 
end 
end 
end 
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), fix) 
bindKey ( "F7", "down", fix) 

Updated !!

Link to comment
  
function fix () 
        if isPedInVehicle( localPlayer ) then 
            local uVehicle = getPedOccupiedVehicle( localPlayer ) 
            if uVehicle then 
            fixVehicle( uVehicle ) 
end 
end 
end 
addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), fix) 
bindKey ( "F7", "down", fix) 

Updated !!

WTF? Why you post this? First, start tabulating your code.

Second, you don't need to fix the vehicle when player spawns.

bindKey('F3','down', 
    function() 
        if isPedInVehicle(localPlayer) then 
            local vehicle = getPedOccupiedVehicle(localPlayer) 
            if vehicle then 
                fixVehicle(vehicle) 
            end 
        end 
    end 
) 

Link to comment

small edit to your script

bindKey('F7','down', 
    function() 
    if isPedInVehicle(localPlayer) then 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle then 
    fixVehicle(vehicle) 
    outputChatBox("Your Vehicle Has Been Fixed",255,255,0) 
    else 
    outputChatBox("You Are Not in Vehicle",255,0,0) 
    end 
end 
end) 

Link to comment
small edit to your script
bindKey('F7','down', 
    function() 
    if isPedInVehicle(localPlayer) then 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle then 
    fixVehicle(vehicle) 
    outputChatBox("Your Vehicle Has Been Fixed",255,255,0) 
    else 
    outputChatBox("You Are Not in Vehicle",255,0,0) 
    end 
end 
end) 

No need to post this, the problem has been solved by Kenix.

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