Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addItem (_source, _name, _amount, _meta)
- _meta = meta or {}
- local item_info = items_table[_name]
- if _amount > 0 then
- local user = exports.redemrp:getPlayerFromId(_source)
- local identifier = user.getIdentifier()
- local charid = user.getSessionVar("charid")
- local player_inventory = inventory_with_data[identifier .. "_" .. charid]
- local player_db_inventory = inventory_without_data[identifier .. "_" .. charid]
- if item_info.type == "item_standard" then
- if inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount) <= 24.0 then
- if player_inventory[_name] then
- player_inventory[_name].amount = player_inventory[_name].amount + _amount
- player_db_inventory[_name].amount = player_db_inventory[_name].amount + _amount
- else
- 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}
- player_db_inventory[_name].amount = _amount
- end
- inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + (item_info.weight * _amount)
- end
- elseif item_info.type == "item_weapon" then
- if inventory_weight[identifier .. "_" .. charid] + item_info.weight <= 24.0 then
- local weaponid = string.format("%03d%04d", math.random(100,999), math.random(0,9999))
- 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}
- player_db_inventory[_name..weaponid].amount = {amount = _amount , meta = _meta}
- end
- inventory_weight[identifier .. "_" .. charid] = inventory_weight[identifier .. "_" .. charid] + item_info.weight
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement