Guest User

Untitled

a guest
Jul 26th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. function addItem (source, name, amount ,meta)
  2. local _source = source
  3. local _name = name
  4. local _amount = amount
  5. local _meta = meta or {}
  6. local item_info = items_table[_name]
  7. if _amount > 0 then
  8. TriggerEvent('redemrp:getPlayerFromId', _source, function(user)
  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. if item_info.type == "item_standard" then
  14. if inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount) <= 24.0 then
  15. if player_inventory[_name] then
  16. player_inventory[_name].amount = player_inventory[_name].amount + _amount
  17. player_db_inventory[_name].amount = player_db_inventory[_name].amount + _amount
  18. else
  19. 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}
  20. player_db_inventory[_name].amount = _amount
  21. end
  22. inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount)
  23. end
  24. elseif item_info.type == "item_weapon" then
  25. if inventory_weight[identifier .. "_" .. charid] + item_info.weight <= 24.0 then
  26. local numBase0 = math.random(100,999)
  27. local numBase1 = math.random(0,9999)
  28. local weaponid = string.format("%03d%04d", numBase0, numBase1)
  29. 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}
  30. player_db_inventory[_name..weaponid].amount = {amount = _amount , meta = _meta}
  31. end
  32. inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + item_info.weight
  33. end
  34. end)
  35. end
  36. end
  37.  
Advertisement
Add Comment
Please, Sign In to add comment