h4x7o0r Posted September 6, 2013 Share Posted September 6, 2013 Hey guys, I tried to find a way when i start a resource to add some vehicle upgrades to some cars. For example. When resource is started, to set default Spoiler id 1003 for car id 415. How can i manage to make it ? Thank in advance. Link to comment
Castillo Posted September 6, 2013 Share Posted September 6, 2013 You must loop all the vehicles, get the model and compare it, then add the upgrade. getElementsByType getElementModel addVehicleUpgrade Link to comment
h4x7o0r Posted September 6, 2013 Author Share Posted September 6, 2013 Thanks for ur reply. function checkveh (veh) for _, v in ipairs(getElementsByType("vehicle")) do if getElementModel (vehicle) == 415 then if not getVehicleUpgradeOnSlot(vehicle, 2) then addVehicleUpgrade ( vehicle, 1003 ) end end end end addEventHandler("onResourceStart",getRootElement(),checkveh) Link to comment
DNL291 Posted September 7, 2013 Share Posted September 7, 2013 function checkveh (veh) for _, v in ipairs(getElementsByType("vehicle")) do if getElementModel (vehicle) == 415 then if not getVehicleUpgradeOnSlot(vehicle, 2) then addVehicleUpgrade ( vehicle, 1003 ) end end end end addEventHandler("onResourceStart",getRootElement(),checkveh) Replace 'vehicle' with 'v'. Link to comment
h4x7o0r Posted September 7, 2013 Author Share Posted September 7, 2013 function checkveh (veh) for _, v in ipairs(getElementsByType("vehicle")) do if getElementModel (v) == 415 then if not getVehicleUpgradeOnSlot(v, 2) then addVehicleUpgrade ( v, 1003 ) end end end end addEventHandler("onResourceStart",getRootElement(),checkveh) No errors but doesn't work. No change. Thanks for reply. Link to comment
Vision Posted September 7, 2013 Share Posted September 7, 2013 Try this function checkveh () for _, v in ipairs(getElementsByType("vehicle")) do if getElementModel (v) == 415 then if getVehicleUpgradeOnSlot(v, 2) ~= 1003 then addVehicleUpgrade ( v, 1003 ) end end end end addEventHandler("onResourceStart",resourceRoot,checkveh) Link to comment
h4x7o0r Posted September 8, 2013 Author Share Posted September 8, 2013 thanks for your reply but doesn't work. No errors. I want it that everytime a vehicle got changed to apply the vehicle upgrade. Link to comment
h4x7o0r Posted September 8, 2013 Author Share Posted September 8, 2013 I mean, spoiler's not on the car after script's starting. Does nothing. Link to comment
Castillo Posted September 8, 2013 Share Posted September 8, 2013 function checkveh ( ) for _, v in ipairs ( getElementsByType ( "vehicle" ) ) do if ( getElementModel ( v ) == 415 ) then if ( getVehicleUpgradeOnSlot ( v, 2 ) ~= 1003 ) then addVehicleUpgrade ( v, 1003 ) outputChatBox ( "ADDING UPGRADE" ) else outputChatBox ( "UPGRADE ALREADY ON SLOT" ) end end end end addEventHandler ( "onResourceStart", resourceRoot, checkveh ) Use that and see what it outputs to the chat box. Link to comment
h4x7o0r Posted September 8, 2013 Author Share Posted September 8, 2013 Solved. Thank you all for your help. 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