Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ItemSets = {}
- local function InventorytypeToSlot(pType)
- if(pType >= 1 and pType <= 10) then
- return pType-1
- elseif(pType == 11) then
- return 10 -- , 11
- elseif(pType == 12) then
- return 12 -- , 13
- elseif(pType == 16) then
- return 14
- elseif(pType == 13) then
- return 20 -- One hand
- elseif(pType == 17 or pType == 21) then
- return 15
- elseif(pType == 20) then
- return 4
- elseif(pType == 22) then
- return 16
- end
- end
- local function LoadItemsets()
- for k, v in pairs(ItemSets) do -- Clear the table for reload
- ItemSets[k] = nil
- end
- local Q = WorldDBQuery("SELECT itemset, inventorytype, entry FROM items WHERE itemset > 0")
- if(Q) then
- for i = 1, Q:GetRowCount() do
- local itemset, entry, slot = Q:GetColumn(0):GetULong(), Q:GetColumn(2):GetULong(), InventorytypeToSlot(Q:GetColumn(1):GetULong())
- if(slot) then
- if(not ItemSets[itemset]) then
- ItemSets[itemset] = {}
- end
- if(not ItemSets[itemset][slot]) then
- ItemSets[itemset][slot] = {}
- end
- table.insert(ItemSets[itemset][slot], entry)
- end
- Q:NextRow()
- end
- end
- end
- LoadItemsets() -- Load the itemsets
- function HasItemset(pPlayer, set)
- if(not ItemSets[set]) then
- return nil -- invalid set
- end
- if(set == 65 or set == 737) then
- local item = pPlayer:GetEquippedItemBySlot(15)
- if(item and (item:GetEntryId() == ItemSets[set][20][1] or item:GetEntryId() == ItemSets[set][20][2])) then
- local item2 = pPlayer:GetEquippedItemBySlot(16)
- if(item2 and (item2:GetEntryId() == ItemSets[set][20][1] or item2:GetEntryId() == ItemSets[set][20][2])) then
- return true
- end
- end
- return false
- end
- for slot,tbl in pairs(ItemSets[set]) do
- local Found = false
- if(slot == 20) then
- for k, entry in ipairs(tbl) do
- local item = pPlayer:GetEquippedItemBySlot(15)
- if(item and item:GetEntryId() == entry) then
- Found = true
- break
- end
- item = pPlayer:GetEquippedItemBySlot(16)
- if(item and item:GetEntryId() == entry) then
- Found = true
- break
- end
- break
- end
- elseif(slot == 10 or slot == 12) then
- local first = false
- for k, entry in ipairs(tbl) do
- local item = pPlayer:GetEquippedItemBySlot(slot)
- if(item and item:GetEntryId() == entry) then
- if(first) then
- Found = true
- break
- else
- first = true;
- end
- end
- item = pPlayer:GetEquippedItemBySlot(slot+1)
- if(item and item:GetEntryId() == entry) then
- if(first) then
- Found = true
- break
- else
- first = true;
- end
- end
- end
- else
- for k, entry in ipairs(tbl) do
- local item = pPlayer:GetEquippedItemBySlot(slot)
- if(item and item:GetEntryId() == entry) then
- Found = true
- break
- end
- end
- end
- if(not Found) then
- return false
- end
- end
- return true
- end
- --[[
- -- Example:
- local function TestFunc(event, pPlayer, Message, Type, Language, Misc)
- if(HasItemset(pPlayer, tonumber(Message))) then -- say some itemset number ingame
- pPlayer:SendAreaTriggerMessage("true")
- else
- pPlayer:SendAreaTriggerMessage("false")
- end
- end
- RegisterServerHook(16, TestFunc)
- -- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement