Vaux42 Posted March 2, 2012 Posted March 2, 2012 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)
Kenix Posted March 2, 2012 Posted March 2, 2012 (edited) 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 March 2, 2012 by Guest
Vaux42 Posted March 2, 2012 Author Posted March 2, 2012 Works perfectly, thanks for the help and the lightning fast reply
Agon Posted March 2, 2012 Posted March 2, 2012 wait.. does it work with function fix ???? shouldn't it be function fix() ??
Evil-Cod3r Posted March 2, 2012 Posted March 2, 2012 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 !!
drk Posted March 2, 2012 Posted March 2, 2012 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 )
Evil-Cod3r Posted March 2, 2012 Posted March 2, 2012 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)
drk Posted March 2, 2012 Posted March 2, 2012 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.
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