• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Need example for PlayerGossipEvent

Status
Not open for further replies.

Kaev

Super Moderator
Heyho, i need an example for the PlayerGossipEvent-hook
This is my code:
Code:
local function talk(event, player, object)
    player:SendBroadcastMessage("test")
end

RegisterPlayerGossipEvent([COLOR="#FF0000"]1[/COLOR], 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)

Thanks
 

Kaev

Super Moderator
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
 

Rochet2

Moderator / Eluna Dev
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.

Example:
Code:
local [COLOR="#00FF00"]MenuId [/COLOR]= 123 -- Unique ID to recognice player gossip menu among others

local function OnGossipHello(event, player)
    player:[COLOR="#00FF00"]GossipClearMenu[/COLOR]() -- 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, [COLOR="#00FF00"]MenuId[/COLOR]) -- MenuId required for player gossip
end

local function OnGossipSelect(event, player, object, sender, intid, code, menuid) -- [COLOR="#00FF00"]object is player, menuid is the MenuId[/COLOR]
    if (intid == 1) then
        player:GossipMenuAddItem(0, "Close gossip", 1, 5)
        player:GossipMenuAddItem(0, "Back ..", 1, 6)
        player:GossipSendMenu(1, player, [COLOR="#00FF00"]MenuId[/COLOR]) -- MenuId required for player gossip
    elseif (intid == 2) then
        OnGossipHello(event, player)
    elseif (intid == 3) then
        player:SendBroadcastMessage(code)
        OnGossipHello(event, player, object)
    elseif (intid == 4) then
        if (player:GetCoinage() >= 50000) then
            player:ModifyMoney(-50000)
        end
        OnGossipHello(event, player)
    elseif (intid == 5) then
        player:GossipComplete()
    elseif (intid == 6) then
        OnGossipHello(event, player)
    end
end

RegisterPlayerGossipEvent([COLOR="#00FF00"]MenuId[/COLOR], 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.
 
Last edited:
Status
Not open for further replies.
Top