Jump to content

Fix Vehicle


Mefisto_PL

Recommended Posts

I wrote a script to fix the car through the Z button, but it shows me the error "Bad argument @'bindkey' "and I have no clue what to do. Please help, and here is the code:

function fix (playerSource) 
    local theVehicle = getPedOccupiedVehicle (playerSource) 
    if theVehicle and getVehicleController ( theVehicle ) == playerSource then 
         fixVehicle (theVehicle) 
    end 
end 
addCommandHandler ("fix" , fix) 
bindKey(source,"z","down",fix) 

Link to comment
addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"z","down",fix) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in ipairs(getElementsByType("player")) do 
        bindKey(player,"z","down",fix) 
    end 
end) 
  
function fix (playerSource) 
    local theVehicle = getPedOccupiedVehicle (playerSource) 
    if (theVehicle and getVehicleController ( theVehicle ) == playerSource) then 
        fixVehicle (theVehicle) 
    end 
end 
addCommandHandler ("fix" , fix) 

Link to comment

Hmm... Can you repair this too?

addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"z","down",fix) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in ipairs(getElementsByType("player")) do 
        bindKey(player,"z","down",fix) 
    end 
end) 
  
function fix (playerSource) 
    local theVehicle = getPedOccupiedVehicle (playerSource) 
    if (theVehicle and getVehicleController ( theVehicle ) == playerSource) then 
        fixVehicle (theVehicle) 
                        local rx, ry, rz = getVehicleRotation ( vehicle ) 
                                        if ( rx > 110 ) and ( rx < 250 ) then 
                                            local x, y, z = getElementPosition ( vehicle ) 
                                            setVehicleRotation ( vehicle, rx + 180, ry, rz ) 
                                            setElementPosition ( vehicle, x, y, z + 2 ) 
    end 
end 
addCommandHandler ("fix" , fix) 

I want add flip to this function. :D

Link to comment
addEventHandler("onPlayerJoin",root, 
function () 
    bindKey(source,"z","down",fix) 
end) 
  
addEventHandler("onResourceStart",resourceRoot, 
function () 
    for index, player in ipairs(getElementsByType("player")) do 
        bindKey(player,"z","down",fix) 
    end 
end) 
  
function fix (playerSource) 
    local theVehicle = getPedOccupiedVehicle (playerSource) 
    if (theVehicle and getVehicleController ( theVehicle ) == playerSource) then 
        fixVehicle (theVehicle) 
        local rx, ry, rz = getVehicleRotation ( theVehicle ) 
        if ( rx > 110 ) and ( rx < 250 ) then 
            local x, y, z = getElementPosition ( theVehicle ) 
            setVehicleRotation ( theVehicle, rx + 180, ry, rz ) 
            setElementPosition ( theVehicle, x, y, z + 2 ) 
        end 
    end 
end 
addCommandHandler ("fix", fix) 

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