Jump to content

[HELP] Script Errors


BolonZX

Recommended Posts

So I'm making this script which consists of a moving steering wheel, however I'm having a few issues

D2BgIX6.png

this is the code:

client

local theWheel = steer_dummy 
  
  
function SteerLeftDown(theVeh, player) 
    local targetPlayer = getLocalPlayer (player) 
    if isPedInVehicle(targetPlayer) then 
        local rx, ry, rz = getVehicleComponentRotation(theVeh, "theWheel") 
        setVehicleComponentRotation(theVeh, "theWheel", rx+1, ry, rz) 
    end 
end 
  
function SteerLeftUp(theVeh, player) 
    local targetPlayer = getLocalPlayer (player) 
    if isPedInVehicle(targetPlayer) then 
        local rx, ry, rz = getVehicleComponentRotation(theVeh, "theWheel") 
        setVehicleComponentRotation(theVeh, "theWheel", rx+1, ry, rz) 
    end 
end 
     
--# Right    
function SteerRightDown(theVeh, player) 
    local targetPlayer = getLocalPlayer (player) 
    if isPedInVehicle(targetPlayer) then 
        local rx, ry, rz = getVehicleComponentRotation(theVeh, "theWheel") 
        setVehicleComponentRotation(theVeh, "theWheel", rx-1, ry, rz) 
    end 
end 
         
function SteerRightUp(theVeh, player) 
    local targetPlayer = getLocalPlayer (player) 
    if isPedInVehicle(targetPlayer) then 
        local rx, ry, rz = getVehicleComponentRotation(theVeh, "theWheel") 
        setVehicleComponentRotation(theVeh, "theWheel", rx-1, ry, rz) 
    end 
end  
  
bindKey("vehicle_left", "down", SteerLeftDown) 
bindKey("vehicle_left", "up", SteerLeftUp) 
bindKey("vehicle_right", "down", SteerRightDown) 
bindKey("vehicle_right", "up", SteerRightUp) 
  

Link to comment

I recommend you to read the wiki page.

Many things wrong:

- Key names

- getLocalPlayer you don't know how to use it

- there is no vehicle in your code you need to check it using getPedOccupiedVehicle.

- Wrong Arguments

Example

function FunctionName(key, keyState) 
    if isPedInVehicle(localPlayer) then 
        local vehicle = getPedOccupiedVehicle (localPlayer) 
            if vehicle then  
            local rx, ry, rz = getVehicleComponentRotation(vehicle, "......") 
                if key == "arrow_l" then  
                    -- Your code here 
                elseif key == "arrow_r" then  
                    -- same thing here 
            end 
        end 
    end  
end  
bindKey("arrow_l", "both", FunctionName) 
bindKey("arrow_r", "both", FunctionName) 

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