This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [LUA] [RELEASE] DB controlled Gossip  (Read 4129 times)

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
[LUA] [RELEASE] DB controlled Gossip
« on: July 08, 2012, 03:25:41 pm »
Hey Modcraft

Some time earlier this year a serverowner asked me to make a script. The server went down the day after though (very poor server, and I was just desperate for ideas for something to make), so I've just had this on my harddrive ever since. And I thought I'd share it with you guys, considering well... Its just rotting on my harddisk, so why not share it?
Its basically a Lua script, which makes a gossip menu and allows the options to be controlled from the database. Pretty straight forward, and rather simple, yet somewhat useful, considering there's no need to reload the Lua scripts, should you want to change it.

Lua (LuaHypArc) Code:
http://pastebin.com/s6YgFRcg

SQL Code:
http://pastebin.com/RagiYHm7

Columns explained:
Entry: Just an entry ID
MenuId: The ID of the menu which that option should belong to.
Name: The name of the option.
IconId: The icon on the start of the option.
NextMenuId: The ID of the menu it should lead to.

To make specific things to happen at one specific option, you're going to have to edit the Lua script.
Like so:
Make the NextMenuId some unused number, and go into the Lua script. Between the first "if (intid == 0) then" and the 'else' for that if statement, you're gonna want to add another "elseif (intid == NumberOfTheUnusedMenuId) then" and then whatever code you want. Quite simple.
Note: It has to be an ElseIf statement. Not just another If statement. Lots of people does that in Lua scripting, and its rather horrible, really.

Well, I guess that's all there is to say about this script. Enjoy!



Thanks
Keta

PS. Yes, I made it myself.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Mordred

  • Contributors
  • Polygonshifter
  • *****
  • Posts: 57
    • View Profile
Re: [LUA] [RELEASE] DB controlled Gossip
« Reply #1 on: July 09, 2012, 01:00:50 pm »
Hey Keta,
nice work
but wouldn't

RegisterUnitGossipEvent(NPCID, 1, NPC_GossipHello)
RegisterUnitGossipEvent(NPCID, 2, NPC_GossipSelect)

mean, that it only works for 1 npc?
So basically you have to create that lua script for every NPC :|

And you can't add an self made npc_text to the menu.
You also should make a type column to add a quest, miscaction or a POI.
and also what would come in handy:
a column for function name, so on menu point pressed a function is called
or maybe other things like spell cast

could be a lot more than just that :p

~Mordred
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Burn in fire of righteousness!
Easy Loginscreen

Keta

  • Contributors
  • Model Change Addict
  • *****
  • Posts: 210
    • View Profile
Re: [LUA] [RELEASE] DB controlled Gossip
« Reply #2 on: July 09, 2012, 05:17:46 pm »
Yes, I could do that. This was merely a quick example to show how these things can be done. The opportunities are endless, so... This hopefully gave people a new understanding of scripting. If not, oh well ^^

Thanks
Keta
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Chronic

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 9
    • View Profile
Re: [LUA] [RELEASE] DB controlled Gossip
« Reply #3 on: February 03, 2013, 02:27:36 am »
There are lot of ways to be done however good job for taking your time to create it
« Last Edit: January 01, 1970, 01:00:00 am by Admin »