Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Proffesion_ONClick(pUnit, event, player)
- proffesionmenu(pUnit, player)
- end
- function proffesionmenu(pUnit, player)
- pUnit:GossipCreateMenu(3802, player, 0)
- local amount = CharDBQuery("SELECT * FROM character_proffesion WHERE name = '"..player:GetName().."';")
- if amount == nil then
- pUnit:GossipMenuAddItem(7, "What's the difference between a miner and a lumberjack?", 5, 0)
- pUnit:GossipMenuAddItem(3, "I would like to become a miner.", 2, 0)
- pUnit:GossipMenuAddItem(3, "I would like to become a lumberjack.", 3, 0)
- else
- if (not player:HasAchievement(116)) then
- player:AddAchievement(116)
- end
- if amount:GetColumn(0):GetString() == "miner" then
- pUnit:GossipMenuAddItem(7, "How does being a miner work?", 9, 0)
- pUnit:GossipMenuAddItem(3, "Unlearn current proffesion.", 6, 0)
- if (not player:HasItem(40893)) then
- player:AddItem(40893,1)
- end
- pUnit:GossipMenuAddItem(3, "Your skill in mining is: "..amount:GetColumn(2):GetString()..".", 4, 0)
- pUnit:GossipMenuAddItem(3, "Show me the items I can create at my current skill level.", 10, 0)
- else
- pUnit:GossipMenuAddItem(7, "How does being a lumberjack work?", 11, 0)
- pUnit:GossipMenuAddItem(3, "Unlearn current proffesion.", 6, 0)
- pUnit:GossipMenuAddItem(3, "Your skill in wood cutting is: "..amount:GetColumn(2):GetString()..".", 4, 0)
- pUnit:GossipMenuAddItem(3, "Show me the items I can create at my current skill level.", 12, 0)
- end
- end
- pUnit:GossipMenuAddItem(0, "Nevermind.", 1, 0)
- pUnit:GossipSendMenu(player)
- end
- function ProffesionOnGossip(pUnit, event, player, id, intid, code)
- if (intid == 1) then
- player:GossipComplete()
- elseif intid == 2 then
- pUnit:CastSpellOnTarget(66390,player)
- player:SendBroadcastMessage("|cffffff00You have learned Mining|r")
- CharDBQuery("INSERT INTO character_proffesion VALUES ('miner','"..player:GetName().."','0');")
- proffesionmenu(pUnit, player)
- elseif intid == 3 then
- pUnit:CastSpellOnTarget(66390,player)
- player:LearnSpell(54705)
- player:SendBroadcastMessage("|cffffff00You have learned Woodcutting|r")
- CharDBQuery("INSERT INTO character_proffesion VALUES ('lumber','"..player:GetName().."','0');")
- proffesionmenu(pUnit, player)
- elseif intid == 4 then
- proffesionmenu(pUnit, player)
- elseif intid == 5 then
- pUnit:GossipCreateMenu(7363, player, 0)
- if pUnit == nil then
- pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
- end
- pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 6 then
- pUnit:GossipCreateMenu(3802, player, 0)
- 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)
- pUnit:GossipMenuAddItem(0, "Yes.", 7, 0)
- pUnit:GossipMenuAddItem(0, "No.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 7 then
- CharDBQuery("DELETE FROM character_proffesion WHERE name = '"..player:GetName().."';")
- if (player:HasItem(40893)) then
- player:RemoveItem(40893,1)
- pUnit:CastSpellOnTarget(46331,player)
- player:SendBroadcastMessage("|cffffff00You have unlearned Mining|r")
- elseif player:HasSpell(54705) == true then
- player:UnlearnSpell(54705)
- player:SendBroadcastMessage("|cffffff00You have unlearned Woodcutting|r")
- pUnit:CastSpellOnTarget(46331,player)
- player:RemoveAura(54705)
- end
- proffesionmenu(pUnit, player)
- elseif intid == 8 then
- if player:GetItemCount(11370) > 9 then
- player:CastSpell(32990)
- player:RemoveItem(11370, 10)
- player:AddItem(2871, 1)
- else
- player:SendBroadcastMessage("You do not have enough Dark Iron Ore.")
- end
- player:GossipComplete()
- elseif intid == 9 then -- miner
- pUnit:GossipCreateMenu(5289, player, 0)
- if pUnit == nil then
- pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
- end
- pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 10 then
- pUnit:GossipCreateMenu(3802, player, 0)
- local amount = CharDBQuery("SELECT skill FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
- pUnit:GossipMenuAddItem(4, "Create a minor sharpening stone. (Costs 10 Dark Iron Ore.)", 8, 0)
- if tonumber(amount) > 14 then
- pUnit:GossipMenuAddItem(4, "Create the Rockshard Spaulders. (Costs 25 Dark Iron Ore.)", 14, 0)
- pUnit:GossipMenuAddItem(4, "Create the Elder Bow. (Costs 25 Dark Iron Ore.)", 15, 0)
- end
- pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 11 then -- lumber
- pUnit:GossipCreateMenu(5116, player, 0)
- if pUnit == nil then
- pUnit:GossipMenuAddItem(0, "debug.", 4, 0)
- end
- pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 12 then
- pUnit:GossipCreateMenu(3802, player, 0)
- pUnit:GossipMenuAddItem(4, "Create a scroll to enchant bracers. (Costs 10 Wood.)", 13, 0)
- local amount = CharDBQuery("SELECT skill FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
- if tonumber(amount) > 14 then
- pUnit:GossipMenuAddItem(4, "Create a scroll to enchant your chest. (Costs 15 Wood.)", 16, 0)
- pUnit:GossipMenuAddItem(4, "Create a scroll to enchant your boots. (Costs 15 Wood.)", 17, 0)
- end
- pUnit:GossipMenuAddItem(0, "Alright.", 4, 0)
- pUnit:GossipSendMenu(player)
- elseif intid == 13 then -- enchant bracer spirit
- if player:GetItemCount(11291) > 9 then
- player:CastSpell(32990)
- player:RemoveItem(11291, 10)
- player:AddItem(38783, 1)
- else
- player:SendBroadcastMessage("You do not have enough wood.")
- end
- player:GossipComplete()
- elseif intid == 14 then -- rockshard spaulders
- if player:GetItemCount(11370) > 24 then
- player:CastSpell(32990)
- player:RemoveItem(11370, 25)
- player:AddItem(9411, 1)
- else
- player:SendBroadcastMessage("You do not have enough dark iron ore.")
- end
- player:GossipComplete()
- elseif intid == 15 then -- Elder bow
- if player:GetItemCount(11370) > 24 then
- player:CastSpell(32990)
- player:RemoveItem(11370, 25)
- player:AddItem(9400, 1)
- else
- player:SendBroadcastMessage("You do not have enough dark iron ore.")
- end
- player:GossipComplete()
- elseif intid == 16 then -- chest
- if player:GetItemCount(11291) > 14 then
- player:CastSpell(32990)
- player:RemoveItem(11291, 15)
- player:AddItem(38865, 1)
- else
- player:SendBroadcastMessage("You do not have enough wood.")
- end
- player:GossipComplete()
- elseif intid == 17 then -- boots
- if player:GetItemCount(11291) > 14 then
- player:CastSpell(32990)
- player:RemoveItem(11291, 15)
- player:AddItem(38837, 1)
- else
- player:SendBroadcastMessage("You do not have enough wood.")
- end
- player:GossipComplete()
- end
- end
- RegisterUnitGossipEvent(122921, 1, "Proffesion_ONClick")
- RegisterUnitGossipEvent(122921, 2, "ProffesionOnGossip")
- -- Mining
- -- Use vein 147516, item 40893
- local CooldownTime = {}
- local ClickPrevent = {}
- function Pickaxe_Proffesion(item, event, player)
- local target = player:GetGameObjectNearestCoords(player:GetX(), player:GetY(), player:GetZ(), 147516)
- if target ~= nil then
- if player:GetDistanceYards(target) < 6.5 then
- if ClickPrevent[player:GetName()] == "clicked" and ((os.clock()-CooldownTime[player:GetName()])) <= 3 then
- player:SendAreaTriggerMessage("|cFFFF0000You have already mined this.")
- else
- ClickPrevent[player:GetName()] = "clicked"
- CooldownTime[player:GetName()] = os.clock()
- local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';")
- if amount ~= nil then
- amount = amount:GetColumn(0):GetString()
- if tonumber(amount) < 26 or tonumber(amount) == 0 then
- CharDBQuery("UPDATE character_proffesion SET `skill` = skill+1 WHERE `name` = '"..player:GetName().."';")
- end
- end
- player:FullCastSpell(32606)
- player:SpawnCreature(77190 ,target:GetX(), target:GetY(), target:GetZ(), 0, 35, 2500) --1600
- target:Despawn(1600, math.random(190000, 1960000))
- end
- else
- player:SendAreaTriggerMessage("|cFFFF0000You need to be closer!")
- end
- else
- player:SendAreaTriggerMessage("|cFFFF0000There is no vein nearby!")
- end
- end
- function additem_toplayer(pUnit,Event)
- local player = pUnit:GetClosestPlayer()
- if player ~= nil then
- player:AddItem(11370, math.random(1,3)) -- Dark Iron Ore
- local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
- player:SendBroadcastMessage("|cff3e3effYour skill in Mining has increased to "..amount..".")
- --player:SendBroadcastMessage("|cffffff00Your skill in mining has increased to "..amount..".")
- end
- end
- RegisterItemGossipEvent(40893, 1, "Pickaxe_Proffesion")
- function OreDummy(pUnit,Event) -- for every node, sadly you need a dummy =(
- pUnit:RegisterEvent("additem_toplayer", 1600, 1)
- end
- RegisterUnitEvent(77190, 18, "OreDummy")
- -- Lumbering
- -- Use westfall trees
- ClickLumberPrevent = {}
- CooldownLumberTime = {}
- function Proffesion_ChopTreeSmall(pUnit, event, player)
- if player:IsMounted() then
- player:Dismount()
- end
- if ClickLumberPrevent[player:GetName()] == "clicked" and ((os.clock()-CooldownLumberTime[player:GetName()])) <= 3 then
- player:SendAreaTriggerMessage("|cFFFF0000You are already chopping this.")
- else
- ClickLumberPrevent[player:GetName()] = "clicked"
- CooldownLumberTime[player:GetName()] = os.clock()
- local amount = CharDBQuery("SELECT * FROM character_proffesion WHERE name = '"..player:GetName().."';")
- if amount:GetColumn(0):GetString() ~= "lumber" then
- player:FullCastSpell(62854)
- pUnit:Kill(pUnit)
- else
- amount = amount:GetColumn(2):GetString()
- player:FullCastSpell(62854)
- pUnit:SetNPCFlags(2)
- if tonumber(amount) < 26 or tonumber(amount) == 0 then
- CharDBQuery("UPDATE character_proffesion SET `skill` = skill+1 WHERE `name` = '"..player:GetName().."';")
- end
- pUnit:SpawnCreature(108292, player:GetX(), player:GetY(), player:GetZ(), 0, 35, 6000)
- end
- end
- end
- RegisterUnitGossipEvent(169772, 1, "Proffesion_ChopTreeSmall")
- function Proffesion_TreeSpawn(pUnit, event)
- pUnit:SetNPCFlags(1)
- end
- RegisterUnitEvent(169772, 18, "Proffesion_TreeSpawn")
- function Proffesion_LumberTrigger(pUnit, event)
- pUnit:RegisterEvent("AdvancedProffesionLumberskill", 1500, 1)
- end
- function AdvancedProffesionLumberskill(pUnit)
- local player = pUnit:GetClosestPlayer()
- if player ~= nil then
- player:AddItem(11291, math.random(1,3)) -- wood
- local amount = CharDBQuery("SELECT `skill` FROM character_proffesion WHERE name = '"..player:GetName().."';"):GetColumn(0):GetString()
- player:SendBroadcastMessage("|cff3e3effYour skill in Wood cutting has increased to "..amount..".")
- --player:SendBroadcastMessage("|cffffff00Your skill in wood cutting has increased to "..amount..".")
- local creature = pUnit:GetCreatureNearestCoords(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 169772)
- if creature ~= nil then
- creature:Kill(creature)
- end
- end
- end
- RegisterUnitEvent(108292, 18, "Proffesion_LumberTrigger")
- --
Advertisement
Add Comment
Please, Sign In to add comment