示例
-- 背包扫描系统
local function ScanPlayerBags(player)
local totalItems = 0
local totalValue = 0
local itemList = {}
-- 扫描主背包和额外背包
for bag = 0, 4 do
local bagSlots = 36 -- 主背包36格,其他背包根据实际情况调整
if bag > 0 then
bagSlots = 16 -- 假设其他背包16格
end
for slot = 0, bagSlots - 1 do
local item = player:GetItemByPos(bag, slot)
if item then
local entry = item:GetEntry()
local count = item:GetCount()
local quality = item:GetQuality()
totalItems = totalItems + count
-- 记录高品质物品
if quality >= 3 then -- 稀有及以上
table.insert(itemList, {
name = item:GetName(),
quality = quality,
count = count
})
end
end
end
end
player:SendBroadcastMessage("背包扫描完成:")
player:SendBroadcastMessage("物品总数: " .. totalItems)
if #itemList > 0 then
player:SendBroadcastMessage("发现稀有物品:")
for _, itemInfo in ipairs(itemList) do
local qualityNames = {"", "", "普通", "稀有", "史诗", "传说"}
local qualityName = qualityNames[itemInfo.quality + 1] or "未知"
player:SendBroadcastMessage("- " .. itemInfo.name .. " x" .. itemInfo.count .. " (" .. qualityName .. ")")
end
end
end
-- 装备检查系统
local function CheckEquipment(player)
local equipSlots = {
[0] = "头部", [1] = "颈部", [2] = "肩部", [4] = "胸部",
[5] = "腰带", [6] = "腿部", [7] = "脚部", [8] = "手腕",
[9] = "手套", [10] = "戒指1", [11] = "戒指2",
[12] = "饰品1", [13] = "饰品2", [14] = "斗篷",
[15] = "主手", [16] = "副手", [17] = "远程"
}
player:SendBroadcastMessage("=== 装备检查 ===")
local emptySlots = 0
for slot, slotName in pairs(equipSlots) do
local item = player:GetItemByPos(255, slot)
if item then
local durability = item:GetDurability()
local maxDurability = item:GetMaxDurability()
if maxDurability > 0 then
local durabilityPercent = (durability / maxDurability) * 100
if durabilityPercent < 25 then
player:SendBroadcastMessage(slotName .. ": " .. item:GetName() .. " (耐久度危险: " .. math.floor(durabilityPercent) .. "%)")
end
end
else
emptySlots = emptySlots + 1
end
end
if emptySlots > 0 then
player:SendBroadcastMessage("空装备槽位: " .. emptySlots .. " 个")
end
end