Jump to content

can't make a simple setVehicleComponentVisible script


DriFtyZ

Recommended Posts

Hello people im new to scripting and i want to make a basic script that disables one vehicle component so i can enable the other on it (like front bumpers) lets say i have the stock front bumper (bump_front_dummy) visible by default and i want to hide it and enable the extra bumper that is on the model file.. im pretty sure this can be achieved somehow but i tried several things to make work without success

links i used to learn:

https://wiki.multitheftauto.com/wiki/GetVehicleComponents

https://wiki.multitheftauto.com/wiki/SetVehicleComponentVisible

here's my script below:

addCommandHandler ( "test",
    function ( )
        local theVehicle = getPedOccupiedVehicle ( localPlayer )
		local Component = getVehicleComponents ( theVehicle )
        if ( theVehicle ) then
            for k in pairs ( Component("bump_front_dummy") ) do
				setVehicleComponentVisible(Component, k , false)
			end
        end
    end
)

 

Link to comment
addCommandHandler ( "remove",
function ( )
	local theVehicle = getPedOccupiedVehicle ( localPlayer )
	if ( theVehicle ) then
		for k in pairs ( getVehicleComponents ( theVehicle ) ) do
			if ( k == "bump_front_dummy" ) then
				setVehicleComponentVisible(theVehicle, k , false)
				break
			end
		end
	end
end
)

 

Note : I've changed 'test' command because it's will not work.

Edited by !#NssoR_)
Link to comment
8 hours ago, !#NssoR_) said:

Note : I've changed 'test' command because it's will not work.

I'm curious why this doesn't work. I wasted lots of time trying to fix a function i made some time ago until i realized that the "test" command never works. 

Link to comment
3 hours ago, koragg said:

I'm curious why this doesn't work. I wasted lots of time trying to fix a function i made some time ago until i realized that the "test" command never works. 

Wiki says : Note: You cannot use "check", "list" or "test" as a command name.

  • Like 1
Link to comment

Sorry i haven't noticed that on the wiki, Thanks for the reply i can now understead how the (k,v in pairs) works now when i want something specific. I started learning lua yesterday :)

Edited by DriFtyZ
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...