Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local NPCID = 24380
- local intidspace = 10
- local minlen = 3
- ---Rochet2 Edition
- local function FindAndDisplayItems(pUnit, player, namepart)
- local Q = WorldDBQuery('SELECT entry, name1 FROM items WHERE name1 LIKE "%'..namepart..'%" LIMIT 30')
- -- Item search, limit to max 30
- if (not Q) then -- check query
- return false
- end
- pUnit:GossipCreateMenu(100, player, 0)
- pUnit:GossipMenuAddItem(0, "Find item", 1, 1, "Insert item name part") --addds a search button on top of the menu
- repeat
- local entry = Q:GetColumn(0):GetULong()
- local name = Q:GetColumn(1):GetString()
- pUnit:GossipMenuAddItem(4, name, entry+intidspace, 0)
- until not Q:NextRow()
- pUnit:GossipSendMenu(player)
- return true
- end
- local function OnGossipHello(pUnit, event, player)
- if (player:IsGm() == true) then
- pUnit:GossipCreateMenu(100, player, 0)
- pUnit:GossipMenuAddItem(0, "Find item", 1, 1, "Insert item name part")
- pUnit:GossipMenuAddItem(5, "[Exit Menu]", 0, 0)
- pUnit:GossipSendMenu(player)
- elseif (player:IsGm() == false) then
- player:SendAreaTriggerMessage("You don't have access to this NPC!")
- player:GossipComplete()
- else
- player:SendBroadcastMessage("[Server Notification][ERROR-MSG:307] Ranking check issue, report to a GM.")
- player:GossipComplete()
- end
- end
- local function OnGossipSelect(pUnit, event, player, id, intid, code)
- if (initd == 0) then
- player:GossipComplete()
- return
- end
- if (intid == 1) then
- if (code) then
- local namepart = code:gsub('\\',''):gsub('"', '')
- if (namepart:len() < minlen) then
- player:SendBroadcastMessage("[Server Notification] must be at least "..minlen.." characters long.")
- else
- if (FindAndDisplayItems(pUnit, player, namepart)) then
- return -- Showing a submenu, so don't show main menu.
- else
- player:SendBroadcastMessage("[Server Notification] No results found.")
- end
- end
- end
- end
- if (intid >= intidspace) then
- local entry = intid-intidspace
- player:SendBroadcastMessage("The item entry was " .. entry)
- end
- OnGossipHello(pUnit, event, player)
- end
- RegisterUnitGossipEvent(NPCID, 1, OnGossipHello)
- RegisterUnitGossipEvent(NPCID, 2, OnGossipSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement