3B00DG4MER Posted January 16, 2015 Share Posted January 16, 2015 Hi Guys i wanted to create a table : it's make all upgrades of cars in the table and set them Available as False then get available Upgrades of current car and remove the upgrade same as the available upgrades and put it in the table and set them available as True Here is the function : function upgrade() local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then return end local allUpgrades = {} local slotName for i=0, 16 do local upgrade = getVehicleUpgradeOnSlot ( vehicle, i ) local upgradeName = getVehicleUpgradeSlotName ( i ) local avFind = table.find(allUpgrades, "av", false ) local nameFind = table.find(allUpgrades, "slotName" ,upgradeName ) if nameFind == false then table.insert(allUpgrades, { [ "av" ] = false, [ "slotName" ] = upgradeName}) end end for i,upgrade in ipairs(getVehicleCompatibleUpgrades(vehicle)) do slotName = getVehicleUpgradeSlotName(upgrade) local nameFind = table.find(allUpgrades, "slotName" ,slotName ) local avFind = table.find(allUpgrades, "av", false ) if (nameFind == true) and (avFind == true) then table.remove(allUpgrades, i) table.insert(allUpgrades, {[ "av" ] = true, [ "slotName" ] = slotName} ) end end return allUpgrades end function table.find(t, ...) local args = { ... } if #args == 0 then for k,v in pairs(t) do if v then return k end end return false end local value = table.remove(args) if value == '[nil]' then value = nil end for k,v in pairs(t) do for i,index in ipairs(args) do if type(index) == 'function' then v = index(v) else if index == '[last]' then index = #v end v = v[index] end end if v == value then return k end end return false end Link to comment
3B00DG4MER Posted January 17, 2015 Author Share Posted January 17, 2015 Guys i need help ! Link to comment
MTA Team botder Posted January 17, 2015 MTA Team Share Posted January 17, 2015 I don't understand your problem. Do you have any warnings/errors in debugscript? What should happen, what does not happen and what is it doing now? Link to comment
3B00DG4MER Posted January 17, 2015 Author Share Posted January 17, 2015 There's no problem in debugscript i want to add all Upgrades of GTA in that table and set availability as false ["av"] = false, ["slotName"] = SlotName (here slot name of Upgrade) then remove upgrades that Compatible the current car and add it but set the availability as true ["av"] = true, ["slotName"] = slotName Link to comment
Et-win Posted January 18, 2015 Share Posted January 18, 2015 --table.insert(allUpgrades, {[ "av" ] = true, [ "slotName" ] = slotName} ) allUpgrades["av"] = true allUpgrades["slotName"] = slotName Etc. 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