Roblox Envanter Mimarisi: Izgara Slotları, Ağırlık Bütçesi & Sunucu Otoritesi

2026-09-29 • DopaBrain Roblox Systems Engineering Team • DopaBrain Engineering

Featured DopaBrain Interactive Tools

Envanter yönetimi, Roblox'taki RPG ve hayatta kalma oyunlarının temelidir. Zayıf mimari eşya çoğaltma açıklarına ve mobil cihazlarda gecikmelere yol açar.

Sunucu yetkili durum makineleri, modüler veri yapıları ve ProfileService oturum kilidi ile binlerce oyuncu için güvenli ve akıcı envanterler tasarlanabilir.

1. Envanter Modelleri: Sabit Slot vs. Izgara vs. Ağırlık Limiti

Oyun dinamiğine en uygun yapının seçilmesi:

2. Sunucu Otoritesi ve İyimser (Optimistic) UI

Güvenlikten ödün vermeden anında tepki sağlama:

3. Veri Yapıları ve İstifleme Optimizasyonu

Luau ile dinamik ve statik verilerin ayrıştırılması:

ServerScriptService.Inventory.InventoryManager
-- Sunucu Yetkili Envanter Yöneticisi
local InventoryManager = {}
InventoryManager.__index = InventoryManager
local ItemDatabase = require(game.ReplicatedStorage.ItemDatabase)

function InventoryManager.new(player, maxSlots, maxWeight)
    local self = setmetatable({}, InventoryManager)
    self.Player = player
    self.MaxSlots = maxSlots or 30
    self.MaxWeight = maxWeight or 100
    self.Slots = table.create(self.MaxSlots, false)
    self.CurrentWeight = 0
    self.IsLocked = false
    return self
end

function InventoryManager:AddItem(itemId, amount)
    if self.IsLocked then return false, "INVENTORY_LOCKED" end
    local itemData = ItemDatabase[itemId]
    if not itemData then return false, "INVALID_ITEM" end
    local addedWeight = itemData.Weight * amount
    if self.CurrentWeight + addedWeight > self.MaxWeight then
        return false, "OVER_ENCUMBERED"
    end
    for slotIndex = 1, self.MaxSlots do
        local slot = self.Slots[slotIndex]
        if slot and slot.Id == itemId and slot.Count < itemData.MaxStack then
            local space = itemData.MaxStack - slot.Count
            local toAdd = math.min(space, amount)
            slot.Count = slot.Count + toAdd
            amount = amount - toAdd
            self.CurrentWeight = self.CurrentWeight + (itemData.Weight * toAdd)
            if amount <= 0 then return true end
        end
    end
    for slotIndex = 1, self.MaxSlots do
        if not self.Slots[slotIndex] then
            self.Slots[slotIndex] = {
                UUID = game:GetService("HttpService"):GenerateGUID(false),
                Id = itemId,
                Count = amount,
                Durability = itemData.MaxDurability
            }
            self.CurrentWeight = self.CurrentWeight + (itemData.Weight * amount)
            return true
        end
    end
    return false, "INVENTORY_FULL"
end

return InventoryManager

4. Eşya Kopyalama (Dupe) Koruması ve Oturum Kilidi

Bağlantı kopması ve takas açıklarının önlenmesi:

5. Mobil Dokunmatik Deneyimi ve Ölçeklendirme

Akıllı telefon ve tabletlerde konforlu kullanım:

Frequently Asked Questions

Envanter mantığı neden kesinlikle sunucuda çalışmalıdır?

İstemci tarafındaki kontroller sahte eşya üretimine ve kopyalama hilelerine zemin hazırlar. Sunucu güvenliği esastır.

İyimser UI gecikmeyi nasıl ortadan kaldırır?

Eşya ekranda hemen hareket eder; sadece sunucu reddederse eski yerine geri çekilir.

Oturum kilidi (Session Locking) ne işe yarar?

Aynı anda iki sunucunun oyuncu verisini değiştirmesini engelleyerek kopma açıklarını kapatır.

Mobilde sürükleme sorunları nasıl çözülür?

Parmağın altında hafif bir geçici kopya yürütülür ve hedef slot sadece parmak bırakıldığında taranır.

Explore More Interactive Tests & Guides

Discover personalized cognitive assessments, stress evaluations, and game psychology tools on DopaBrain.

Go to Portal Hub