Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local T = {}
- T.Items =
- {
- -- {GivenItem, ReqItem1, ReqItem2, ... ReqItemN}
- {25, 35, 36},
- {25, 37, 38, 39},
- {25, 40},
- {25, 41},
- }
- T.Page = {}
- T.Options = 20
- function T.Count(Page)
- if(not Page or Page < 1) then
- return 1
- else
- return (Page*T.Options)
- end
- end
- function T.Max(Count, LData)
- if(LData - Count >= T.Options) then
- return Count+T.Options-1, true
- else
- return LData, false
- end
- end
- function T.Hello(pUnit, event, pPlayer)
- local str = tostring(pPlayer)
- if(not T.Page[str] or T.Page[str] < 0) then
- T.Page[str] = 0
- end
- local Page = T.Page[str]
- local Count = T.Count(Page)
- local Max, Next = T.Max(Count, #T.Items)
- pUnit:GossipCreateMenu(1000, pPlayer, 0)
- -- for k, v in ipairs(T.Items) do
- for k = 1, #T.Items do
- local Add = true
- for i = 2, #T.Items[k] do
- if(not pPlayer:HasItem(T.Items[k][i])) then
- Add = false
- end
- end
- if(Add) then
- local Name = WorldDBQuery("SELECT Name1 FROM items WHERE entry = "..T.Items[k][1]):GetColumn(0):GetString()
- pUnit:GossipMenuAddItem(0, Name, k, 0)
- end
- end
- if(Next) then
- pUnit:GossipMenuAddItem(7, "Next page", 490, 0, '', 0)
- end
- if(Page > 0) then
- pUnit:GossipMenuAddItem(7, "Previous page", 491, 0, '', 0)
- end
- pUnit:GossipSendMenu(pPlayer)
- end
- function T.Select(pUnit, event, pPlayer, id, intid, code)
- if(T.Items[intid]) then
- if(pPlayer:AddItem(T.Items[intid][1], 1)) then
- for i = 2, #T.Items[intid] do
- pPlayer:RemoveItem(T.Items[intid][i], 1)
- end
- else
- pPlayer:SendAreaTriggerMessage("Your inventory is full")
- end
- end
- T.Hello(pUnit, event, pPlayer)
- end
- local ID = 6948 -- NPC entry
- RegisterUnitGossipEvent(ID, 1, T.Hello)
- RegisterUnitGossipEvent(ID, 2, T.Select)
- -- RegisterItemGossipEvent(ID, 1, T.Hello)
- -- RegisterItemGossipEvent(ID, 2, T.Select)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement