Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ## Gurubashi Theme Generator ##
- Original credits to Hkarta.
- Base for this script here by Sdyess:
- http://www.ac-web.org/forums/showthread.php?t=150939
- Modified to lua by Rochet2
- Use the SQL provieded by Sdyess!
- ]]
- local NPCID = 123123 -- NPC ENTRY HERE
- local OFFSET_THEME = 1000
- local function GetLastThemeTime()
- local Q = WorldDBQuery("SELECT `time` FROM `gurubashi_lastspawned`")
- if (Q) then
- return Q:GetColumn(0):GetUInt32()
- else
- return 0
- end
- end
- local function GossipObjects(player, m_creature)
- m_creature:GossipCreateMenu(1, pPlayer, 0)
- if (GetLastThemeTime() + 600 <= os.time()) then
- local Q = WorldDBQuery("SELECT `id`, `name` FROM `gurubashi_themes`")
- if (Q) then
- for i = 1, Q:GetRowCount() do
- m_creature:GossipMenuAddItem(4, Q:GetColumn(1):GetString(), OFFSET_THEME + Q:GetColumn(0):GetInt32(), 0)
- Q:NextRow()
- end
- end
- else
- local time2 = GetLastThemeTime() + 600 - os.time()
- local msg = ""
- if (time2 < 60) then
- msg = "Next change possible in less than minute."
- else
- msg = "Next change possible in "..(time2 / 60).." minute/s."
- end
- m_creature:GossipMenuAddItem(0, msg, 2, 0)
- end
- m_creature:GossipMenuAddItem(0, "Good bye", 1, 0)
- m_creature:GossipSendMenu(player)
- end
- local function OnGossipHello(pCreature, event, pPlayer)
- GossipObjects(pPlayer, pCreature)
- end
- local function OnGossipSelect(m_creature, event, player, sender, action, code)
- if (action > OFFSET_THEME) then
- WorldDBQuery("DELETE FROM `gurubashi_lastspawned`")
- WorldDBQuery("INSERT INTO `gurubashi_lastspawned` VALUES ("..os.time()..")")
- local Q = WorldDBQuery("SELECT `x`, `y`, `z`, `o`, `entry` FROM `gurubashi_spawns` WHERE `theme` = "..(action - OFFSET_THEME))
- if (Q) then
- player:SendAreaTriggerMessage(12, 0, "Spawning gameobjects..")
- for i = 1, Q:GetRowCount() do
- m_creature:SpawnGameObject(Q:GetColumn(4):GetInt32(), Q:GetColumn(0):GetFloat(), Q:GetColumn(1):GetFloat(), Q:GetColumn(2):GetFloat(), Q:GetColumn(3):GetFloat(), 600000, 100)
- Q:NextRow()
- end
- else
- player:SendAreaTriggerMessage("No gameobjects found")
- OnGossipHello(m_creature, event, player)
- end
- elseif(action == 1) then
- player:GossipComplete()
- elseif(action == 2) then
- GossipObjects(player, m_creature)
- end
- end
- RegisterUnitGossipEvent(NPCID, 1, OnGossipHello)
- RegisterUnitGossipEvent(NPCID, 2, OnGossipSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement