Results 1 to 2 of 2
  1. #1
    TechnoJacker's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    226
    Reputation
    13
    Thanks
    9,487
    My Mood
    Tired

    Somewhat future proof Give/Remove Item script

    Somewhat future proof Give/Remove Item script

    I seen many scripts floating about that lets you give yourself items, the more popular one right now has you manually listing each item. Well, I made my own which that lets you give yourself items without having to keep updating a list. It reads the items straight from the game. Its quite robust (Yea, I was bored) and lets you give yourself certain items you want, all items or even certain types of items like just only masks.

    I gave a brief description and example usage in the script itself in case you need help using it. Also the script should be good to go as is, by default, it will clear all your old stuff and give you 20 of everything. It also can be used to unlock all the items, including weapons as well as remove the new item flags (The little exclamation marks) from new items in your inventory.

    Code:
    -- Function to check if value is in table
    function in_table( table, value )
      if table ~= nil then for i,x in pairs(table) do if x == value then return true end end end
      return false
    end
    
    -------------------------------------------------------------------------
    --giveitems( itype, times )
    --[[
    Gives all items for the corresponding item type for the specified number of times. Default is 5 items per use.
    Usage:
    This gives you 5 of every item
    giveitems("all")
    You can specify the type, for example this gives you 5 of every mask
    giveitems("masks")
    You can also pass along a table of only certain item types you want
    giveitems({"masks","textures","colors"})
    --]]
    function giveitems( itype, times )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        local skip = { masks = {"character_locked"}, materials = {"plastic"}, colors = {"nothing"}, textures = {"no_color_full_material","no_color_no_material"} }
        if not times then times = 5 end
        if type(itype) == "table" then types = itype end
        if itype == "all" or type(itype) == "table" then
          for i = 1, #types do giveitems(types[i], times) end
          return
        elseif not in_table(types, itype) then return end
        for i=1, times do
                for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                    if not in_table(skip[itype], mat_id) then
                        local global_value = "normal"
                        if _.global_value then
                                  global_value = _.global_value
                          elseif _.infamous then
                                  global_value = "infamous"
                          elseif _.dlcs or _.dlc then
                              local dlcs = _.dlcs or {}
                              if _.dlc then table.insert( dlcs, _.dlc ) end
                              global_value = dlcs[ math.random( #dlcs ) ]
                          end
                          if _.unlocked == false then _.unlocked = true end
                          managers.blackmarket:add_to_inventory(global_value, itype, mat_id, false)
                      end
                  end
        end
    end
    
    -------------------------------------------------------------------------
    --giveitem( item, times , global_value)
    --[[
    Gives you a certain item for the specified number of times. Default is 5 items per use.
    By specifying global_value, you can change the item from its default global value like "normal" and "infamous"
    Usage:
    This gives you 5 of the slime material
    giveitem("slime")
    This gives you 5 of the Alien mask
    giveitem("alienware")
    You can also pass along a table of only certain items you want
    giveitem({"slime","rainbow","alienware"})
    --]]
    function giveitem( item, times , global_value)
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if not times then times = 5 end
        for t = 1, #types do
            local itype = types[t]
                for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                    if (type(item) == "table" and in_table(item, mat_id)) or (type(item) ~= "table" and mat_id == item) then
                        if not global_value then
                            local global_value = "normal"
                            if _.global_value then
                                      global_value = _.global_value
                              elseif _.infamous then
                                      global_value = "infamous"
                              elseif _.dlcs or _.dlc then
                                  local dlcs = _.dlcs or {}
                                  if _.dlc then table.insert( dlcs, _.dlc ) end
                                  global_value = dlcs[ math.random( #dlcs ) ]
                              end
                          end
                          if _.unlocked == false then _.unlocked = true end
                          for i=1, times do managers.blackmarket:add_to_inventory(global_value, itype, mat_id, false) end
                          if type(item) ~= "table" then return end
                      end
                  end
        end
    end
    
    -------------------------------------------------------------------------
    --removeitems( itype, times )
    --[[
    Removes items from a given type, out dated, see clearitems below
    --]]
    function removeitems( itype, times )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if not times then times = 100 end
        if type(itype) == "table" then types = itype end
        if itype == "all" or type(itype) == "table" then
          for i = 1, #types do removeitems(types[i], times) end
          return
        elseif not in_table(types, itype) then return end
        for i=1, times do
                for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                    managers.blackmarket:remove_item("normal", itype, mat_id)
                    managers.blackmarket:remove_item("infamous", itype, mat_id)
                    if _.global_value then
                              managers.blackmarket:remove_item(_.global_value, itype, mat_id)
                      elseif _.dlcs or _.dlc then
                          local dlcs = _.dlcs or {}
                          if _.dlc then table.insert( dlcs, _.dlc ) end
                          for i = 1, #dlcs do managers.blackmarket:remove_item(dlcs[i], itype, mat_id) end
                      end
                  end
          end
    end
    
    -------------------------------------------------------------------------
    --removeitems( item, times )
    --[[
    Removes a given item, out dated, see clearitem below
    --]]
    function removeitem( item, times )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if not times then times = 100 end
        for t = 1, #types do
            local itype = types[t]
                for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                    if (type(item) == "table" and in_table(item, mat_id)) or (type(item) ~= "table" and mat_id == item) then
                        local global_value = { "normal" }
                        if _.global_value then
                                  global_value = { _.global_value }
                          elseif _.infamous then
                                  global_value = { "infamous" }
                          elseif _.dlcs or _.dlc then
                              global_value = _.dlcs or {}
                              if _.dlc then table.insert( global_value, _.dlc ) end
                          end
                          for g = 1, #global_value do
                              for i=1, times do managers.blackmarket:remove_item(global_value[g], itype, mat_id) end
                          end
                          if type(item) ~= "table" then return end
                      end
                  end
        end
    end
    
    -------------------------------------------------------------------------
    --clearitems( itype , globalval )
    --[[
    Clears the items of the specified type with the specified (optional) global value, the global value defaults to all.
    Usage:
    This removes every item
    clearitems("all")
    You can specify the type, for example this removes all the masks
    clearitems("masks")
    You can also pass along a table of only certain item types you want to remove
    clearitems({"masks","textures","colors"})
    With the optional global value, you can remove only certain items like all halloween masks
    clearitems("masks", "halloween")
    --]]
    function clearitems( itype , globalval )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if not globalval then globalval = "all" end
        if type(itype) == "table" then types = itype end
        if itype == "all" or type(itype) == "table" then
          for i = 1, #types do clearitems(types[i], globalval) end return
        elseif not in_table(types, itype) then return end
        for global_value, categories in pairs( Global.blackmarket_manager.inventory ) do
                if (globalval == "all" or globalval == global_value) and categories[itype] then
                      for id,amount in pairs( categories[itype] ) do
                    Global.blackmarket_manager.inventory[global_value][itype][id] = 0
                end
            end
        end
    end
    
    -------------------------------------------------------------------------
    --clearitem( item , globalval )
    --[[
    Clears the given item with the specified (optional) global value, the global value defaults to all.
    Usage:
    This removes all slime materials
    clearitem("slime")
    This removes all the alien masks
    clearitem("alienware")
    You can also pass along a table of only certain items you want to remove
    clearitem({"slime","rainbow","alienware"})
    --]]
    function clearitem( item , globalval )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if not globalval then globalval = "all" end
        for t = 1, #types do
            local itype = types[t]
            for global_value, categories in pairs( Global.blackmarket_manager.inventory ) do
                    if (globalval == "all" or globalval == global_value) and categories[itype] then
                          for id,amount in pairs( categories[itype] ) do
                        if (type(item) == "table" and in_table(item, id)) or (type(item) ~= "table" and id == item) then
                            Global.blackmarket_manager.inventory[global_value][itype][id] = 0
                        end
                    end
                end
            end
        end
    end
    
    -------------------------------------------------------------------------
    --clearnewitems( itype )
    --[[
    Clears the new item flags from the given types
    --]]
    function clearnewitems( itype )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors"}
        if type(itype) == "table" then types = itype end
        if itype == "all" or type(itype) == "table" then
          for i = 1, #types do clearnewitems(types[i]) end
          return
        elseif not in_table(types, itype) then return end
            for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                local global_value = { "normal" }
                if _.global_value then
                          global_value = { _.global_value }
                  elseif _.infamous then
                          global_value = { "infamous" }
                  elseif _.dlcs or _.dlc then
                      global_value = _.dlcs or {}
                      if _.dlc then table.insert( global_value, _.dlc ) end
                  end
                  for i = 1, #global_value do
                      if managers.blackmarket:got_new_drop( global_value[i], itype, mat_id ) then
                    managers.blackmarket:remove_new_drop( global_value[i], itype, mat_id )
                end
                  end
        end
    end
    
    -------------------------------------------------------------------------
    --unlockitems( itype )
    --[[
    Unlocks items from the given type
    --]]
    function unlockitems( itype )
        local types = {"weapon_mods", "masks", "materials", "textures", "colors", "weapons"}
        if type(itype) == "table" then types = itype end
        if itype == "all" or type(itype) == "table" then
          for i = 1, #types do unlockitems(types[i]) end
          return
        elseif not in_table(types, itype) then return end
        if itype == "weapons" then
          for wep_id,_ in pairs(tweak_data.upgrades.definitions) do
            if _.category == "weapon" and not string.find(wep_id, "_primary") and not string.find(wep_id, "_secondary") then
                if not managers.upgrades:aquired(wep_id) then managers.upgrades:aquire(wep_id) end
            end
          end
            else
              for mat_id,_ in pairs(tweak_data.blackmarket[itype]) do
                if _.unlocked == false then _.unlocked = true end
              end
            end
    end
    --------------------------------------------------------------
    if managers and managers.menu_component then
      managers.menu_component:post_event("menu_enter")
    end
    --------------------------------------------------------------
    clearitems("all")
    giveitems("all", 20)
    Examples:
    Code:
    giveitems
    -----------------------------------------
    Gives all items for the corresponding item type for the specified number of times. Default is 5 items per use.
    Usage:
    This gives you 5 of every item
    giveitems("all")
    You can specify the type, for example this gives you 5 of every mask
    giveitems("masks")
    You can also pass along a table of only certain item types you want
    giveitems({"masks","textures","colors"})
    ++++++++++++++++++++++++++++++++++++++++++++++++
    giveitem
    -----------------------------------------
    Gives you a certain item for the specified number of times. Default is 5 items per use.
    By specifying global_value, you can change the item from its default global value like "normal" and "infamous"
    Usage:
    This gives you 5 of the slime material
    giveitem("slime")
    This gives you 5 of the Alien mask
    giveitem("alienware")
    You can also pass along a table of only certain items you want
    giveitem({"slime","rainbow","alienware"})
    ++++++++++++++++++++++++++++++++++++++++++++++++
    clearitems
    -----------------------------------------
    Clears the items of the specified type with the specified (optional) global value, the global value defaults to all.
    Usage:
    This removes every item
    clearitems("all")
    You can specify the type, for example this removes all the masks
    clearitems("masks")
    You can also pass along a table of only certain item types you want to remove
    clearitems({"masks","textures","colors"})
    With the optional global value, you can remove only certain items like all halloween masks
    clearitems("masks", "halloween")
    ++++++++++++++++++++++++++++++++++++++++++++++++
    clearitem
    -----------------------------------------
    Clears the given item with the specified (optional) global value, the global value defaults to all.
    Usage:
    This removes all slime materials
    clearitem("slime")
    This removes all the alien masks
    clearitem("alienware")
    You can also pass along a table of only certain items you want to remove
    clearitem({"slime","rainbow","alienware"})
    ++++++++++++++++++++++++++++++++++++++++++++++++
    clearnewitems
    Clears the new item flags from the given types
    ++++++++++++++++++++++++++++++++++++++++++++++++
    unlockitems
    Unlocks items from the given type, including weapons

  2. #2
    xiang94's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    24
    Reputation
    10
    Thanks
    0
    Nice work Techno!

    P.S: Could you please check your PMs?

Similar Threads

  1. [REQUEST]Remove items script
    By g1160517rmqkrnet in forum Payday 2 Hacks & Cheats
    Replies: 0
    Last Post: 08-27-2013, 01:33 PM
  2. [Help] Smithing item scripts?
    By newport111 in forum Runescape Hacks / Bots
    Replies: 6
    Last Post: 05-01-2011, 08:27 AM
  3. [Help]Removing item from listbox [solved]
    By pushdis15 in forum Visual Basic Programming
    Replies: 9
    Last Post: 04-14-2011, 08:47 PM
  4. [Help]Removing items from ListViewEx? [Solved]
    By Invidus in forum Visual Basic Programming
    Replies: 5
    Last Post: 09-24-2010, 02:57 PM