function vRPin.buyItem(idname, amount) local user_id = vRP.getUserId({source}) local player = vRP.getUserSource({user_id}) if not user_id then return end local shop = openInventories[user_id] if not shop then return end if (vRP.getUserFaction({user_id,"Politie"})) and string.match(idname, "WEAPON_") then if vRP.getUserHoursPlayed({user_id}) < 0 then return vRPclient.notify(player, {"Eroare: Nu ai 0 ore pentru a cumpara arme"}) end end if (vRP.getUserFaction({user_id,"Diicot"})) and string.match(idname, "WEAPON_") then if vRP.getUserHoursPlayed({user_id}) < 0 then return vRPclient.notify(player, {"Eroare: Nu ai 0 ore pentru a cumpara arme"}) end end if string.match(idname, "ammo-") then local currentAmmo = vRP.getInventoryItemAmount({user_id, idname}) or 0 local maxAmmo = 300 if currentAmmo >= maxAmmo then return vRPclient.notify(player, {"Eroare: Nu poti cumpara mai multe gloante!"}) end if currentAmmo + amount > maxAmmo then amount = maxAmmo - currentAmmo end end local price = Config.Shops[shop].items[idname] local itemWeight = vRP.getItemWeight({idname}) * amount if vRP.getInventoryWeight({user_id}) + itemWeight > vRP.getInventoryMaxWeight({user_id}) then return end if vRP.tryPayment({user_id, amount * price}) then vRP.giveInventoryItem({user_id, idname, amount, true}) INclient.loadPlayerInventory(player) end end function openShop(user_id, player, shop) INclient.openInventory(player, {"shop", true}) openInventories[user_id] = shop local items = {} for item, price in pairs(Config.Shops[shop].items) do local item_name,description,weight = vRP.getItemDefinition({item}) if item_name ~= nil then items[#items+1] = { label = item_name, price = price, description = description, name = item, weight = weight, count = 1 } end end INclient.setSecondInventoryItems(player, {items, 0, 0, shop}) end function vRPin.openShop(name, pos) local user_id = vRP.getUserId({source}) if user_id then -- if (Config.Shops[name].permission and vRP.isUserInFaction{user_id, Config.Shops[name].permission}) or (Config.Shops[name].permission == vRP.getFactionType({vRP.getUserFaction{user_id}}) or not Config.Shops[name].permission) then -- if Config.Shops[name].permission and (vRP.getUserFaction({user_id}) == Config.Shops[name].permission or (vRP.getUserFaction({user_id}) and vRP.getFactionType({vRP.getUserFaction({user_id})})) == Config.Shops[name].factionType) or Config.Shops[name].permission == nil then local id = "shops:".. name .. tostring(pos.x) openShop(user_id, source, name) end end end