Advertisement
actuallykane

Untitled

Jul 27th, 2020 (edited)
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function addItem (_source, _name, _amount, _meta)
  2.     _meta = meta or {}
  3.  
  4.     local item_info = items_table[_name]
  5.  
  6.     if _amount > 0 then
  7.         local user = exports.redemrp:getPlayerFromId(_source)
  8.  
  9.         local identifier = user.getIdentifier()
  10.         local charid = user.getSessionVar("charid")
  11.         local player_inventory =  inventory_with_data[identifier .. "_" .. charid]
  12.         local player_db_inventory =  inventory_without_data[identifier .. "_" .. charid]
  13.  
  14.         if item_info.type == "item_standard" then
  15.             if inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount) <= 24.0 then
  16.                 if player_inventory[_name] then
  17.                     player_inventory[_name].amount = player_inventory[_name].amount + _amount
  18.                     player_db_inventory[_name].amount = player_db_inventory[_name].amount + _amount
  19.                 else
  20.                     inventory[identifier .. "_" .. charid][_name] = {name = _name, amount = _amount, meta = _meta, label = item_info.label, description = item_info.description, imgsrc = item_info.imgsrc , weight = item_info.weight, staticData = item_info.staticData}
  21.                     player_db_inventory[_name].amount = _amount
  22.                 end
  23.                 inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount)
  24.             end
  25.         elseif item_info.type == "item_weapon" then
  26.             if inventory_weight[identifier .. "_" .. charid] + item_info.weight <= 24.0 then
  27.                 local weaponid = string.format("%03d%04d", math.random(100,999), math.random(0,9999))
  28.                 inventory[identifier .. "_" .. charid][_name..weaponid] = {name = _name..weaponid, amount = _amount, meta = _meta, label = item_info.label, description = item_info.description, imgsrc = item_info.imgsrc , weight = item_info.weight, staticData = item_info.staticData}
  29.                 player_db_inventory[_name..weaponid].amount = {amount = _amount , meta = _meta}
  30.             end
  31.             inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + item_info.weight
  32.         end
  33.     end
  34. end
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement