stoneharry

Untitled

Nov 24th, 2011
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.10 KB | None | 0 0
  1.  
  2. function Proffesion_ONClick(pUnit, event, player)
  3.     proffesionmenu(pUnit, player)
  4. end
  5.  
  6. function proffesionmenu(pUnit, player)
  7.     pUnit:GossipCreateMenu(3802, player, 0)
  8.     local amount = CharDBQuery("SELECT * FROM character_proffesion WHERE name = '"..player:GetName().."';")
  9.     if amount == nil then
  10.         pUnit:GossipMenuAddItem(7, "What's the difference between a miner and a lumberjack?", 5, 0)
  11.         pUnit:GossipMenuAddItem(3, "I would like to become a miner.", 2, 0)
  12.         pUnit:GossipMenuAddItem(3, "I would like to become a lumberjack.", 3, 0)
  13.     else
  14.         if (not player:HasAchievement(116)) then
  15.             player:AddAchievement(116)
  16.         end
  17.         if amount:GetColumn(0):GetString() == "miner" then
  18.             pUnit:GossipMenuAddItem(7, "How does being a miner work?", 9, 0)
  19.             pUnit:GossipMenuAddItem(3, "Unlearn current proffesion.", 6, 0)
  20.             if (not player:HasItem(40893)) then
  21.                 player:AddItem(40893,1)
  22.             end
  23.             pUnit:GossipMenuAddItem(3, "Your skill in mining is: "..amount:GetColumn(2):GetString()..".", 4, 0)
  24.             pUnit:GossipMenuAddItem(3, "Show me the items I can create at my current skill level.", 10, 0)
  25.         else
  26.             pUnit:GossipMenuAddItem(7, "How does being a lumberjack work?", 11, 0)
  27.             pUnit:GossipMenuAddItem(3, "Unlearn current proffesion.", 6, 0)
  28.             pUnit:GossipMenuAddItem(3, "Your skill in wood cutting is: "..amount:GetColumn(2):GetString()..".", 4, 0)
  29.             pUnit:GossipMenuAddItem(3, "Show me the items I can create at my current skill level.", 12, 0)
  30.         end
  31.     end
  32.     pUnit:GossipMenuAddItem(0, "Nevermind.", 1, 0)
  33.     pUnit:GossipSendMenu(player)
  34. end
  35.  
  36. function ProffesionOnGossip(pUnit, event, player, id, intid, code)
  37.     if (intid == 1) then
  38.         player:GossipComplete()
  39.     elseif intid == 2 then
  40.     pUnit:CastSpellOnTarget(66390,player)
  41.         player:SendBroadcastMessage("|cffffff00You have learned Mining|r")
  42.         CharDBQuery("INSERT INTO character_proffesion VALUES ('miner','"..player:GetName().."','0');")
  43.         proffesionmenu(pUnit, player)
  44.     elseif intid == 3 then
  45.     pUnit:CastSpellOnTarget(66390,player)
  46.         player:LearnSpell(54705)
  47.         player:SendBroadcastMessage("|cffffff00You have learned Woodcutting|r")
  48.         CharDBQuery("INSERT INTO character_proffesion VALUES ('lumber','"..player:GetName().."','0');")
  49.         proffesionmenu(pUnit, player)
  50.     elseif intid == 4 then
  51.         proffesionmenu(pUnit, player)
  52.     elseif intid == 5 then
  53.         pUnit:GossipCreateMenu(7363, player, 0)
  54.         if pUnit == nil then
  55.             pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
  56.         end
  57.         pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
  58.         pUnit:GossipSendMenu(player)
  59.     elseif intid == 6 then
  60.         pUnit:GossipCreateMenu(3802, player, 0)
  61.         pUnit:GossipMenuAddItem(4, "Are you sure you wish to unlearn your current proffesion? (You will loose your skill level and it cannot be recovered!)", 6, 0)
  62.         pUnit:GossipMenuAddItem(0, "Yes.", 7, 0)
  63.         pUnit:GossipMenuAddItem(0, "No.", 4, 0)
  64.         pUnit:GossipSendMenu(player)
  65.     elseif intid == 7 then
  66.         CharDBQuery("DELETE FROM character_proffesion WHERE name = '"..player:GetName().."';")
  67.         if (player:HasItem(40893)) then
  68.             player:RemoveItem(40893,1)
  69.             pUnit:CastSpellOnTarget(46331,player)
  70.             player:SendBroadcastMessage("|cffffff00You have unlearned Mining|r")
  71.         elseif player:HasSpell(54705) == true then         
  72.             player:UnlearnSpell(54705)
  73.             player:SendBroadcastMessage("|cffffff00You have unlearned Woodcutting|r")
  74.             pUnit:CastSpellOnTarget(46331,player)
  75.              player:RemoveAura(54705)
  76.         end
  77.         proffesionmenu(pUnit, player)
  78.     elseif intid == 8 then
  79.         if player:GetItemCount(11370) > 9 then
  80.         player:CastSpell(32990)
  81.             player:RemoveItem(11370, 10)
  82.             player:AddItem(2871, 1)
  83.         else
  84.             player:SendBroadcastMessage("You do not have enough Dark Iron Ore.")
  85.         end
  86.         player:GossipComplete()
  87.     elseif intid == 9 then -- miner
  88.         pUnit:GossipCreateMenu(5289, player, 0)
  89.         if pUnit == nil then
  90.             pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
  91.         end
  92.         pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
  93.         pUnit:GossipSendMenu(player)   
  94.     elseif intid == 10 then
  95.         pUnit:GossipCreateMenu(3802, player, 0)
  96.         local amount = CharDBQuery("SELECT skill FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
  97.         pUnit:GossipMenuAddItem(4, "Create a minor sharpening stone.                (Costs 10 Dark Iron Ore.)", 8, 0)
  98.         if tonumber(amount) > 14 then
  99.             pUnit:GossipMenuAddItem(4, "Create the Rockshard Spaulders.                     (Costs 25 Dark Iron Ore.)", 14, 0)
  100.             pUnit:GossipMenuAddItem(4, "Create the Elder Bow.                               (Costs 25 Dark Iron Ore.)", 15, 0)
  101.         end
  102.         pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
  103.         pUnit:GossipSendMenu(player)   
  104.     elseif intid == 11 then -- lumber
  105.         pUnit:GossipCreateMenu(5116, player, 0)
  106.         if pUnit == nil then
  107.             pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
  108.         end
  109.         pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
  110.         pUnit:GossipSendMenu(player)   
  111.     elseif intid == 12 then
  112.         pUnit:GossipCreateMenu(3802, player, 0)
  113.         pUnit:GossipMenuAddItem(4, "Create a scroll to enchant bracers.             (Costs 10 Wood.)", 13, 0)
  114.         local amount = CharDBQuery("SELECT skill FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
  115.         if tonumber(amount) > 14 then
  116.             pUnit:GossipMenuAddItem(4, "Create a scroll to enchant your chest.      (Costs 15 Wood.)", 16, 0)
  117.             pUnit:GossipMenuAddItem(4, "Create a scroll to enchant your boots.      (Costs 15 Wood.)", 17, 0)
  118.         end
  119.         pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
  120.         pUnit:GossipSendMenu(player)   
  121.     elseif intid == 13 then -- enchant bracer spirit
  122.         if player:GetItemCount(11291) > 9 then
  123.         player:CastSpell(32990)
  124.             player:RemoveItem(11291, 10)
  125.             player:AddItem(38783, 1)
  126.         else
  127.             player:SendBroadcastMessage("You do not have enough wood.")
  128.         end
  129.         player:GossipComplete()
  130.     elseif intid == 14 then -- rockshard spaulders
  131.         if player:GetItemCount(11370) > 24 then
  132.         player:CastSpell(32990)
  133.             player:RemoveItem(11370, 25)
  134.             player:AddItem(9411, 1)
  135.         else
  136.             player:SendBroadcastMessage("You do not have enough dark iron ore.")
  137.         end
  138.         player:GossipComplete()
  139.     elseif intid == 15 then -- Elder bow
  140.         if player:GetItemCount(11370) > 24 then
  141.         player:CastSpell(32990)
  142.             player:RemoveItem(11370, 25)
  143.             player:AddItem(9400, 1)
  144.         else
  145.             player:SendBroadcastMessage("You do not have enough dark iron ore.")
  146.         end
  147.         player:GossipComplete()
  148.     elseif intid == 16 then -- chest
  149.         if player:GetItemCount(11291) > 14 then
  150.             player:CastSpell(32990)
  151.             player:RemoveItem(11291, 15)
  152.             player:AddItem(38865, 1)
  153.         else
  154.             player:SendBroadcastMessage("You do not have enough wood.")
  155.         end
  156.         player:GossipComplete()
  157.     elseif intid == 17 then -- boots
  158.         if player:GetItemCount(11291) > 14 then
  159.             player:CastSpell(32990)
  160.             player:RemoveItem(11291, 15)
  161.             player:AddItem(38837, 1)
  162.         else
  163.             player:SendBroadcastMessage("You do not have enough wood.")
  164.         end
  165.         player:GossipComplete()
  166.     end
  167. end
  168.  
  169. RegisterUnitGossipEvent(122921, 1, "Proffesion_ONClick")
  170. RegisterUnitGossipEvent(122921, 2, "ProffesionOnGossip")
  171.  
  172. -- Mining
  173. -- Use vein 147516, item 40893
  174.  
  175. local CooldownTime = {}
  176. local ClickPrevent = {}
  177.  
  178. function Pickaxe_Proffesion(item, event, player)
  179.     local target = player:GetGameObjectNearestCoords(player:GetX(), player:GetY(), player:GetZ(), 147516)
  180.     if target ~= nil then
  181.         if player:GetDistanceYards(target) < 6.5 then
  182.             if ClickPrevent[player:GetName()] == "clicked" and ((os.clock()-CooldownTime[player:GetName()])) <= 3 then
  183.                 player:SendAreaTriggerMessage("|cFFFF0000You have already mined this.")
  184.             else
  185.                 ClickPrevent[player:GetName()] = "clicked"
  186.                 CooldownTime[player:GetName()] = os.clock()
  187.                 local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';")
  188.                 if amount ~= nil then
  189.                     amount = amount:GetColumn(0):GetString()
  190.                     if tonumber(amount) < 26 or tonumber(amount) == 0 then
  191.                         CharDBQuery("UPDATE character_proffesion SET `skill` = skill+1 WHERE `name` = '"..player:GetName().."';")
  192.                     end
  193.                 end
  194.                 player:FullCastSpell(32606)
  195.                 player:SpawnCreature(77190 ,target:GetX(), target:GetY(), target:GetZ(), 0, 35, 2500) --1600
  196.                 target:Despawn(1600, math.random(190000, 1960000))
  197.             end
  198.         else
  199.             player:SendAreaTriggerMessage("|cFFFF0000You need to be closer!")
  200.         end
  201.     else
  202.         player:SendAreaTriggerMessage("|cFFFF0000There is no vein nearby!")
  203.     end
  204. end
  205.  
  206. function additem_toplayer(pUnit,Event)
  207.     local player = pUnit:GetClosestPlayer()
  208.     if player ~= nil then
  209.         player:AddItem(11370, math.random(1,3)) -- Dark Iron Ore
  210.         local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
  211.         player:SendBroadcastMessage("|cff3e3effYour skill in Mining has increased to "..amount..".")
  212.         --player:SendBroadcastMessage("|cffffff00Your skill in mining has increased to "..amount..".")
  213.     end
  214. end
  215.  
  216.  
  217. RegisterItemGossipEvent(40893, 1, "Pickaxe_Proffesion")
  218.  
  219. function OreDummy(pUnit,Event) -- for every node, sadly you need a dummy =(
  220.     pUnit:RegisterEvent("additem_toplayer", 1600, 1)
  221. end
  222.  
  223. RegisterUnitEvent(77190, 18, "OreDummy")
  224.  
  225. -- Lumbering
  226. -- Use westfall trees
  227.  
  228. ClickLumberPrevent = {}
  229. CooldownLumberTime = {}
  230.  
  231. function Proffesion_ChopTreeSmall(pUnit, event, player)
  232.     if player:IsMounted() then
  233.         player:Dismount()
  234.     end
  235.     if ClickLumberPrevent[player:GetName()] == "clicked" and ((os.clock()-CooldownLumberTime[player:GetName()])) <= 3 then
  236.         player:SendAreaTriggerMessage("|cFFFF0000You are already chopping this.")
  237.     else
  238.         ClickLumberPrevent[player:GetName()] = "clicked"
  239.         CooldownLumberTime[player:GetName()] = os.clock()
  240.         local amount = CharDBQuery("SELECT * FROM character_proffesion WHERE name = '"..player:GetName().."';")
  241.         if amount:GetColumn(0):GetString() ~= "lumber" then
  242.             player:FullCastSpell(62854)
  243.             pUnit:Kill(pUnit)
  244.         else
  245.             amount = amount:GetColumn(2):GetString()
  246.             player:FullCastSpell(62854)
  247.             pUnit:SetNPCFlags(2)
  248.             if tonumber(amount) < 26 or tonumber(amount) == 0 then
  249.                 CharDBQuery("UPDATE character_proffesion SET `skill` = skill+1 WHERE `name` = '"..player:GetName().."';")
  250.             end
  251.             pUnit:SpawnCreature(108292, player:GetX(), player:GetY(), player:GetZ(), 0, 35, 6000)
  252.         end
  253.     end
  254. end
  255.  
  256. RegisterUnitGossipEvent(169772, 1, "Proffesion_ChopTreeSmall")
  257.  
  258. function Proffesion_TreeSpawn(pUnit, event)
  259.     pUnit:SetNPCFlags(1)
  260. end
  261.  
  262. RegisterUnitEvent(169772, 18, "Proffesion_TreeSpawn")
  263.  
  264. function Proffesion_LumberTrigger(pUnit, event)
  265.     pUnit:RegisterEvent("AdvancedProffesionLumberskill", 1500, 1)
  266. end
  267.  
  268. function AdvancedProffesionLumberskill(pUnit)
  269.     local player = pUnit:GetClosestPlayer()
  270.     if player ~= nil then
  271.         player:AddItem(11291, math.random(1,3)) -- wood
  272.         local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
  273.         player:SendBroadcastMessage("|cff3e3effYour skill in Wood cutting has increased to "..amount..".")
  274.         --player:SendBroadcastMessage("|cffffff00Your skill in wood cutting has increased to "..amount..".")
  275.         local creature = pUnit:GetCreatureNearestCoords(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 169772)
  276.         if creature ~= nil then
  277.             creature:Kill(creature)
  278.         end
  279.     end
  280. end
  281.  
  282. RegisterUnitEvent(108292, 18, "Proffesion_LumberTrigger")
  283.  
  284. --
  285.  
Advertisement
Add Comment
Please, Sign In to add comment