DriFtyZ Posted May 13, 2017 Share Posted May 13, 2017 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
!#NssoR_) Posted May 14, 2017 Share Posted May 14, 2017 (edited) 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 May 14, 2017 by !#NssoR_) Link to comment
koragg Posted May 14, 2017 Share Posted May 14, 2017 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
Captain Cody Posted May 14, 2017 Share Posted May 14, 2017 addCommandHandler ( "remove", function ( ) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if ( theVehicle ) then setVehicleComponentVisible(theVehicle, "bump_front_dummy" , false) end end ) ..... 1 Link to comment
!#NssoR_) Posted May 14, 2017 Share Posted May 14, 2017 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. 1 Link to comment
DriFtyZ Posted May 15, 2017 Author Share Posted May 15, 2017 (edited) 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 May 15, 2017 by DriFtyZ Link to comment
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