Jump to content

How to check if vehicle has component?


FuriouZ

Recommended Posts

Hello!

I am working on a vehicle system, inspired from IVF.

So, not all the vehicle mods using the same style to do their stuff, probably modders know what I'm talking about..

Anyways, I don't really know how to explain that...

How I can check, if the vehicle has the component what's needed?

And then how i should check, what sort of "definition" it have?

I don't really know how to do it, but it should look something like that:

        local theVeh = getPedOccupiedVehicle ( localPlayer ) 
        if ( theVeh ) then   
            for k in pairs ( getVehicleComponents ( theVeh ) ) do 
                if k == movsteer then 
                    local strwh_type = "movsteer" 
                elseif k == steeringok then 
                    local strwh_type = "steeringok" 
                elseif k == steering_ok then 
                    local strwh_type = "steering_ok"               
                end 
            end 
        end 
---or this? 
        local theVeh = getPedOccupiedVehicle ( localPlayer ) 
        if ( theVeh ) then   
           -- for k in pairs ( getVehicleComponents ( theVeh ) ) do 
                if getVehicleComponents ( theVeh ) == "movsteer" then 
                    local strwh_type = movsteer 
                elseif getVehicleComponents ( theVeh ) == "steeringok" then 
                    local strwh_type = steeringok 
                elseif getVehicleComponents ( theVeh ) == "steering_ok" then 
                    local strwh_type = steering_ok               
                end 
            --end 
        end 
             
--another thing 
local mvstr_rx, mvstr_ry, mvstr_rz = getVehicleComponentRotation(theVeh, strwh_type) 
  

Yes, I am really bad at explaining and my english isn't good..

Link to comment

First one is almost correct, the problems I see are:

1º You forgot the quotes in the strings, instead of:

if k == movsteer then 

you should do:

if ( k == "movsteer" ) then 

And, your "strwh_type" variable is local, which means it won't exist outside that 'if' statement.

Link to comment
First one is almost correct, the problems I see are:

1º You forgot the quotes in the strings, instead of:

if k == movsteer then 

you should do:

if ( k == "movsteer" ) then 

And, your "strwh_type" variable is local, which means it won't exist outside that 'if' statement.

Oh, THANK YOU ! :)

A little demostration :)

- Front brake calipers 100%

- Steering wheels 100%

- Moving spoilers 0%

- Rear brake calipers 0%

- Other features 0%

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