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 http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Vaux42 Posted March 2, 2012 Author Posted March 2, 2012 Works perfectly, thanks for the help and the lightning fast reply
Kenix Posted March 2, 2012 Posted March 2, 2012 No problem. Post updated. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
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 !! My in-game nick is |['Dev-PoinT_SA']| addEventHandler ( "onPlayerSpawn", getRootElement(), function() if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then triggerClientEvent("BlaBlaBla",getRootElement()) DxDrawText("Hi Dev-PoinT") end end)
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 ) EPT Team Server Development: 0% Learning C++ | C++ is amazing
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) My in-game nick is |['Dev-PoinT_SA']| addEventHandler ( "onPlayerSpawn", getRootElement(), function() if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then triggerClientEvent("BlaBlaBla",getRootElement()) DxDrawText("Hi Dev-PoinT") 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. EPT Team Server Development: 0% Learning C++ | C++ is amazing
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