Hey guys..I found a thread on Index of / about gossip scripts. and i thought id share it with mmowned
Credits - some unregistered member of luaplusplus.org
Well, after getting pissed at this project because it was the only link between me and Lua-powered gossip npcs, I finally decided to look into the whole deal. Took all of a few minutes sadly and I wasted way more time than that getting mad at some of the devs here for almost no reason. Personal stuff aside, here's what I found.
Apparently, the gossip functions in the svn vary from the ones used in almost any example script I could find. I guess the easy way to convey this is throw together a function reference and give you an example script.
GossipCreateMenu
Called from - Unit
Arg1 Integer - Text ID. Not entirely sure what it's used for but I'm guessing high and random numbers are a safe bet.
Arg2 Pointer - Player you're creating the menu for.
Example: Unit:GossipCreateMenu(3543, Player)
GossipMenuAddItem
Called from - Unit
Arg1 Pointer - Player you're creating the menu for.
Arg2 Integer - Icon display ID for gears,chat bubbles, and whatever else there is
Arg3 String - Displayed text for this menu item
Arg4 Integer - Number used with Gossip_Select
Arg5 Integer - Code menu. Shown(1) or not(0)
Example: Unit:GossipMenuAddItem(Player, 4, "Text displayed to the player!", 0, 0)
GossipSendMenu
Called from - Unit
Arg1 Pointer - Player to send the menu to.
Example: Unit:GossipSendMenu(Player)
Note: I'm not taking credit for this script in full but I simply made modifications to it to get it to work. I don't remember who the original creator is.
Source code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Code:function NPC_main_menu(unit, player) unit:GossipCreateMenu(3543, player) -- unit:GossipMenuAddItem(target_player, icon_id, "menu_text", int_id, extra) -- icond_id - id of an icon (chat bubble, gear, e.t.c) -- int_id - id of your menu for gossip_select function unit:GossipMenuAddItem(player,4, "menu_text1", 0, 0) unit:GossipMenuAddItem(player,4, "menu_text2", 1, 0) unit:GossipMenuAddItem(player,4, "menu_text3", 2, 1) -- extra - 1/0 enable/disable enter code menu. unit:GossipSendMenu(player) end function NPC_on_gossip_talk(unit, event, player) NPC_main_menu(unit, player) end function NPC_on_gossip_select(unit, event, player, id, intid, code) if(intid == 0) then unit:SendChatMessage(12, 0, "you are selected menu 0") player:GossipComplete() end if(intid == 1) then unit:SendChatMessage(12, 0, "you are selected menu 1") player:GossipComplete() end if(intid == 2) then unit:SendChatMessage(12, 0, "you are wrong!") if(code == 'abcd') then unit:SendChatMessage(12, 0, "you have entered right code(abcd)") end player:GossipComplete() end end RegisterGossipEvent(200000, 1, "NPC_on_gossip_talk") RegisterGossipEvent(200000, 2, "NPC_on_gossip_select")