View Full Version : Need example for PlayerGossipEvent

11-03-2014, 04:23 PM
Heyho, i need an example for the PlayerGossipEvent-hook
This is my code:

local function talk(event, player, object)

RegisterPlayerGossipEvent(1, 1, talk)

I think the red one is wrong, but i can't figure what "menu_id" i have to use for a player (or better a player corpse)


11-03-2014, 04:38 PM

menu id, event id and function name

Though, I think you would use a different event for that because it's just broadcasting a message

11-03-2014, 04:52 PM
Ofcourse i would do something else, but i just wanted a short example for this hook.
Which menu id is it? Where do i take this from? In my example i used 1, because i didn't knew what i should choose. Nothing triggers, when i rightclick a player. Maybe i understood the hook completely wrong? :s

11-03-2014, 05:36 PM
Player gossip is triggered by other functions, like OnChat etc

http://emudevs.com/showthread.php/2907-Example-ItemUpgrader See this as an example of player gossip being triggered by a spell cast/item use.

11-03-2014, 06:11 PM
You can not use the player gossip select hook alone. Show full code if that is not it.
The menu sent requires the menu_id sent with it. Then it is used to trigger the correct gossip select code.


local MenuId = 123 -- Unique ID to recognice player gossip menu among others

local function OnGossipHello(event, player)
player:GossipClearMenu() -- required for player gossip
player:GossipMenuAddItem(0, "Open submenu", 1, 1)
player:GossipMenuAddItem(0, "Test popup box", 1, 2, "Test popup")
player:GossipMenuAddItem(0, "Test codebox", 1, 3, nil, true)
player:GossipMenuAddItem(0, "Test money requirement", 1, 4, nil, nil, 50000)
player:GossipSendMenu(1, player, MenuId) -- MenuId required for player gossip

local function OnGossipSelect(event, player, object, sender, intid, code, menuid) -- object is player, menuid is the MenuId
if (intid == 1) then
player:GossipMenuAddItem(0, "Close gossip", 1, 5)
player:GossipMenuAddItem(0, "Back ..", 1, 6)
player:GossipSendMenu(1, player, MenuId) -- MenuId required for player gossip
elseif (intid == 2) then
OnGossipHello(event, player)
elseif (intid == 3) then
OnGossipHello(event, player, object)
elseif (intid == 4) then
if (player:GetCoinage() >= 50000) then
OnGossipHello(event, player)
elseif (intid == 5) then
elseif (intid == 6) then
OnGossipHello(event, player)

RegisterPlayerGossipEvent(MenuId, 2, OnGossipSelect)

Do note that this code does not have gossip hello function registered to anything since there is no gossip hello hook for player.
The menu must be sent from some other event.

11-03-2014, 06:24 PM
Hm, the name of the hook misled me this time. :/
Modify the core to trigger an event on looting/talking to a corpse is the only way then afaik, e.g. http://emudevs.com/showthread.php/1200-loot-on-player-corpse