-- Beispiel: Eine Loot-Kiste mit dynamischem Loot basierend auf der Seltenheit erstellen
-- Vergiss nicht, das Event je nach Anwendungsfall irgendwie abzusichern, sonst können Cheater es einfach auslösen, um kostenlosen Loot zu bekommen
RegisterNetEvent('myresource:openLootCrate', function(rarity)
local playerId = source
-- Loot-Pools basierend auf der Seltenheit definieren
local lootPools = {
common = {
minTypes = 1,
maxTypes = 2,
items = {
{ name = "water", chance = 15, min = 1, max = 3 },
{ name = "bread", chance = 15, min = 1, max = 2 },
{ name = "bandage", chance = 10, min = 1, max = 2 },
}
},
rare = {
minTypes = 2,
maxTypes = 4,
items = {
{ name = "water", chance = 10, min = 2, max = 4 },
{ name = "bread", chance = 8, min = 2, max = 3 },
{ name = "bandage", chance = 8, min = 2, max = 3 },
{ name = "lockpick", chance = 5, min = 1, max = 2 },
{ name = "weapon_pistol", chance = 2, min = 1, max = 1 },
}
},
legendary = {
minTypes = 3,
maxTypes = 5,
items = {
{ name = "water", chance = 8, min = 3, max = 5 },
{ name = "bandage", chance = 8, min = 3, max = 4 },
{ name = "lockpick", chance = 6, min = 2, max = 3 },
{ name = "weapon_pistol", chance = 4, min = 1, max = 1 },
{ name = "weapon_rifle", chance = 2, min = 1, max = 1 },
}
}
}
local selectedLoot = lootPools[rarity] or lootPools.common
local inventory = exports['jaksam_inventory']:createInventory(
nil, -- ID automatisch generieren
"Loot Crate (" .. rarity .. ")", -- Dynamisches Label
{
temporary = true, -- Inventar geht beim Script-Neustart verloren
maxSlots = 5,
maxWeight = 50.0,
disableIncoming = true, -- Items können vom Spieler nicht zu diesem Inventar hinzugefügt werden
prefillItems = selectedLoot,
revealItems = {
delayPerItem = 1000,
randomOrder = true
}
},
nil,
'stash',
nil
)
-- Das Inventar-Interface für den Spieler öffnen
if inventory then
exports['jaksam_inventory']:forceOpenInventory(playerId, inventory.id)
end
end)