Advertisement
Guest User

Unknown's Player Menu

a guest
Jun 6th, 2015
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.51 KB | None | 0 0
  1. local command = "menu" -- Usage: .menu
  2.  
  3. local hearthstone = {}
  4.  
  5. -------------------Gossip Section-----------------
  6.  
  7. local T = {
  8.        ["Main"] = {
  9.     {"|TInterface\\icons\\Spell_Shadow_TwistedFaith.png:30|tHearthstone", 1},
  10.     {"|TInterface\\icons\\INV_Misc_Book_11.png:30|tRule Book", 20},
  11.     {"|cffffff00[Exit Menu]|r", 999}
  12.    },
  13.        ["HSs"] = {
  14.     {"|TInterface\\icons\\Achievement_Zone_Northrend_01.png:30|tSave my location", 9},
  15.     {"|cffffff00[Main Menu]|r", 1000}
  16.     },
  17.        ["HSt"] = {
  18.     {"|TInterface\\icons\\Spell_Arcane_TeleportSilvermoon.png:30|tTeleport Me", 10},
  19.     {"|TInterface\\icons\\Achievement_Zone_Northrend_01.png:30|tChange My Location", 9},
  20.     {"|cffffff00[Main Menu]|r", 1000}
  21.      },
  22.        ["Rules"] = {
  23.     {"|TInterface\\icons\\INV_MISC_NOTE_02.png:30|tGeneral Rules", 21},
  24.     {"|TInterface\\icons\\INV_MISC_NOTE_02.png:30|tPlayer Rules", 22},
  25.     {"|cffffff00[Main Menu]|r", 1000}
  26.    },
  27.      ["GenR"] = {
  28.     {"|cffff0000Do not Flame or insult other members.", 21},
  29.     {"|cffff0000Do not Bypass the swear filter or other filters.", 21},
  30.     {"|cffff0000Do not Spread personally identifiable information (i.e. name, address, email, phone number, etc.)", 21},
  31.     {"|cffff0000Do not Racism, discrimination", 21},
  32.     {"|cffff0000Do not Bash any of the staff and the choices they make", 21},
  33.     {"|cffff0000Do not Soliciting, auctioning, selling, advertising, referrals", 21},
  34.     {"|cffff0000Do not Hack", 21},
  35.     {"|cffff0000Do not Cheat", 21},
  36.     {"|cffff0000Do not Bug Exploit", 21},
  37.     {"|cffff0000Do not advertise", 21},
  38.     {"|cffffff00[Back]|r", 20}
  39.  },
  40.   ["PlyR"] = {
  41.     {"|cffff0000No asking GMs for in-game currency or items", 22},
  42.     {"|cffff0000No abusive conduct", 22},
  43.     {"|cffff0000No posing as a staff member", 22},
  44.     {"|cffff0000No abusing the ticket system", 22},
  45.     {"|cffff0000No Win trading", 22},
  46.     {"|cffff0000No Honor Farming", 22},
  47.     {"|cffff0000Do not AFK in BG's", 22},
  48.     {"|cffffff00[Back]|r", 20}
  49.   },
  50. };
  51.  
  52. do
  53.     local Q = CharDBQuery("SELECT * FROM hearthstone")
  54.     if (Q) then
  55.         repeat
  56.             local data = Q:GetRow()
  57.             hearthstone[data.guid] = data
  58.         until not Q:NextRow()
  59.     end
  60. end
  61.  
  62. local function Hello(event, player)
  63.     player:GossipClearMenu()
  64.       for k, v in ipairs(T["Main"]) do
  65.         player:GossipMenuAddItem(0, v[1], 0, v[2])
  66.       end
  67.     player:GossipSendMenu(1, player, 100)
  68.     player:SendAreaTriggerMessage("|cff00ff00Greetings, "..player:GetName().."!|r")
  69. end
  70.  
  71. local function OnSelect(event, player, _, _, intid, code)
  72.     player:GossipClearMenu()
  73.  
  74.     local guid = player:GetGUIDLow()
  75.  
  76.     ----------------------Hearthstone-------------------------
  77.  
  78.     if (intid == 1) then --- Hearthstone Menu
  79.         if (not hearthstone[guid]) then
  80.             for k, v in ipairs(T["HSs"]) do
  81.               player:GossipMenuAddItem(0, v[1], 0, v[2])
  82.             end
  83.         else
  84.             for k, v in ipairs(T["HSt"]) do
  85.               player:GossipMenuAddItem(0, v[1], 0, v[2])
  86.             end
  87.         end
  88.         player:GossipSendMenu(1, player, 100)
  89.  
  90.     elseif (intid == 9) then --- Hearthstone Save
  91.     if(player:GetLuaCooldown() == 0) then
  92.     player:SetLuaCooldown(180)
  93.         local map,x,y,z,o = player:GetMapId(), player:GetLocation()
  94.         hearthstone[guid] = {guid=guid,map=map,x=x,y=y,z=z,o=o}
  95.         CharDBExecute("REPLACE INTO hearthstone (`guid`, `map`, `x`, `y`, `z`, `o`) VALUES ("..guid..", "..string.format("%u, %f, %f, %f, %f", map,x,y,z,o)..")")
  96.         player:SendAreaTriggerMessage("|cff00ff00Your location have been stored!|r")
  97.         player:GossipComplete()
  98.     else
  99.         player:SendBroadcastMessage(string.format("|cff00ffff[Hearthstone]|r|cffff0000 Your hearthstone is on cooldown, %s seconds left.|r", math.ceil(player:GetLuaCooldown())))
  100.     end
  101.  
  102.     elseif (intid == 10) then --- Hearthstone Teleport
  103.   if(player:GetLuaCooldown() == 0) then
  104.     player:SetLuaCooldown(180)
  105.         player:GossipComplete()
  106.         local data = hearthstone[guid]
  107.         if (data) then
  108.             player:Teleport(data.map,data.x,data.y,data.z,data.o)
  109.         end
  110.     else
  111.          player:SendBroadcastMessage(string.format("|cff00ffff[Hearthstone]|r|cffff0000 Your hearthstone is on cooldown, %s seconds left.|r", math.ceil(player:GetLuaCooldown())))
  112.         end
  113.  
  114.     ----------------------Rule-Book-------------------------
  115.  
  116.    elseif(intid == 20) then --- Rules Menu
  117.      for k, v in ipairs(T["Rules"]) do
  118.         player:GossipMenuAddItem(0, v[1], 0, v[2])
  119.         player:GossipSendMenu(1, player, 100)
  120.  
  121.      end
  122.  
  123.     elseif(intid == 21) then --- General Rules
  124.       for k, v in ipairs(T["GenR"]) do
  125.         player:GossipMenuAddItem(0, v[1], 0, v[2])
  126.         player:GossipSendMenu(1, player, 100)
  127.       end
  128.  
  129.     elseif(intid == 22) then --- Player Rules
  130.       for k, v in ipairs(T["PlyR"]) do
  131.         player:GossipMenuAddItem(0, v[1], 0, v[2])
  132.         player:GossipSendMenu(1, player, 100)
  133.       end
  134.  
  135.         -------------------OTHER----------------
  136.  
  137.     elseif(intid == 1000) then --- Main Menu
  138.       for k, v in ipairs(T["Main"]) do
  139.          player:GossipMenuAddItem(0, v[1], 0, v[2])
  140.          player:GossipSendMenu(1, player, 100)
  141.       end
  142.  
  143.     elseif(intid == 999) then --- Exit Menu
  144.       player:GossipComplete()
  145.  
  146.     end
  147. end
  148.  
  149. local function OnCommand(event, player, cmd)
  150.     if (cmd:lower() == command) then
  151.         Hello(event, player)
  152.     end
  153. end
  154.  
  155. RegisterPlayerEvent(42, OnCommand)
  156. RegisterPlayerGossipEvent(100, 2, OnSelect)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement