All pastes #393865 Raw Edit

1.16

public text v1 · immutable
·published 2007-03-13 21:58 UTC
rendered paste body
-- version 1.16a (multilanguage support)
-- Create the Mango Script Base object
-- Sanaell creation
--
My_Teleporter = Mango.Scripts.Create('my_instance');
My_Teleporter:ForceLUA(); -- Don't use the CPP version if valid

-- Function prototypes (to keep it clean)
local My_Teleporter_GossipHello
local My_Teleporter_GossipSelect
local My_Teleporter_CheckPlayer
local My_Teleporter_SendDefaultMenu
local My_Teleporter_SendInstanceMenu

GOSSIP_SENDER_INSTANCE= 7

-- LANGUAGE (EN= English / DE= German) Default is French you can add more language easyly
lng = "FR"

-- instances main menu
don_choice = {"Instances (Level 13-17)   Prix: 5 Po", "Instances (Level 22-29)   Prix: 10 Po", "Instances (Level 33-44)   Prix: 20 Po", "Instances (Level 45-52)   Prix: 40 Po", "Instances (Level 55-60)   Prix: 80 Po", "Raids (Level 60+)             Prix: 200 Po" }
if lng == "EN" then don_choice = {"Instances (Level 13-17)   Price: 5 Gold", "Instances (Level 22-29)   Price: 10 Gold", "Instances (Level 33-44)   Price: 20 Gold", "Instances (Level 45-52)   Price: 40 Gold", "Instances (Level 55-60)   Price: 80 Gold", "Raids (Level 60+)             Price: 200 Gold" } end
if lng == "DE" then don_choice = {"Instances (Level 13-17)   Price: 5 Gold", "Instances (Level 22-29)   Price: 10 Gold", "Instances (Level 33-44)   Price: 20 Gold", "Instances (Level 45-52)   Price: 40 Gold", "Instances (Level 55-60)   Price: 80 Gold", "Raids (Level 60+)             Price: 200 Gold" } end

-- instances prices
price = { 50000, 100000, 200000, 400000, 800000, 2000000 }

-- instances min level 13 to 17
instance1 = { "Le Gouffre de Ragefeu (13-18)" , "La Caverne des lamentations (17-24)" , "Les Mortemines (17-26)" }
if lng == "EN" then instance1 = { "Ragefire Chasm (13-18)" , "Wailing Caverns (17-24)" , "The Deadmines (17-26)" } end
if lng == "DE" then instance1 = { "Ragefireabgrund (13-18)" , "Die H\195\182hlen des Wehklagens (17-24)" , "Die Todesminen (17-26)" } end
instcoord1 = { 389, 3.25, -16.5, -18.3, 4.5, 43, -163.35, 131.49, -73.70, 6, 36, -15.95, -377.01, 60.60, 2.89 }
inst1level = { 13, 17, 17 }

-- instance min level 22 to 29
instance2 = { "Le Donjon d\'Ombrecroc (22-30)" , "Les Profondeurs de Brassenoire (24-32)", "Le Kraal de Tranchebauge (25-30)", "Gnomeregan (29-38)" }
if lng == "EN" then instance2 = { "Shadowfang Keep (22-30)" , "Blackfathom Deeps (24-32)", "Razorfen Kraul (25-30)", "Gnomeregan (29-38)" } end
if lng == "DE" then instance2 = { "Burg Shadowfang (22-30)" , "Blackfathom-Tiefen (24-32)", "Der Kral von Razorfen (25-30)", "Gnomeregan (29-38)" } end
instcoord2 = { 0, -237.90, 1510.50, 75.36, 2.3, 48, -152.49, 102.79, -40.73, 4.23, 1, -4468.41, -1672.81, 81.84, 4.34, 0, -5179.82, 682.93, 379.35, 1.50 }
inst2level = { 22, 24, 25, 29 }

-- instance min level 33 to 44
instance3 = { "Les Souilles de Tranchebauge (33-45)", "Le Monast\195\168re \195\169carlate (34-45)", "Uldaman (35-47)", "Zul\'Farrak (44-54)" }
if lng == "EN" then instance3 = { "Razorfen Downs (33-45)", "Scarlet Monastery (34-45)", "Uldaman (35-47)", "Zul\'Farrak (44-54)" } end
if lng == "DE" then instance3 = { "Die H\195\188gel von Razorfen (33-45)", "Das scharlachrote Kloster (34-45)", "Uldaman (35-47)", "Zul\'Farrak (44-54)" } end
instcoord3 = { 129, 2593.53, 1106.08, 51.44, 4.46, 0, 2847.39, -699.08, 139.34, 5.17, 70, -227.86, 52.19, -46.04, 1.50, 209, 1219.90, 848.60, 10.15, 5.75 }
inst3level = { 33, 34, 35, 44 }

-- instance min level 45 to 52
instance4 = { "Le temple englouti (45-55)", "Maraudon (46-55)", "Les Profondeurs de Blackrock (52-60)" }
if lng == "EN" then instance4 = { "The Sunken Temple (45-55)", "Maraudon (46-55)", "Blackrock Depths (52-60)" } end
if lng == "DE" then instance4 = { "Der versunkene Tempel (45-55)", "Maraudon (46-55)", "Blackrocktiefen (52-60)" } end
instcoord4 = { 109, -320.65, 99.84, -131.85, 3.19, 349, 423.39, 26.21, -132.43, 3.96, 230, 456.65, 29.36, -70.47, 5.16 }
inst4level = { 45, 46, 52 }

-- instance min level 55 to 58
instance5 = { "Hache-Tripes (55-60)", "Scholomance (57-60)", "Stratholme (58-60)", "Le Pic de Blackrock (58-60)", "Le Repaire de l\'Aile noire (58-60)", "C\197\147ur du Magma (58-60)" }
if lng == "EN" then instance5 = { "Dire Maul (55-60)", "Scholomance (57-60)", "Stratholme (58-60)", "Blackrock Spire (58-60)", "Blackwing Lair (58-60)", "Molten Core (58-60)" } end
if lng == "DE" then instance5 = { "D\195\188sterbruch (55-60)", "Scholomance (57-60)", "Stratholme (58-60)", "Blackrockspitze (58-60)", "Pechschwingenhort (58-60)", "Geschmolzener Kern (58-60)" } end
instcoord5 = { 1, -3772.53, 1185.90, 127.44, 5.57, 289, 201.65, 128.14, 134.92, 4.68, 0, 3356.82, -3379.40, 144.79, 0, 229, 78.91, -230.18, 50.24, 4.8, 469, -7666.35, -1101.79, 399.68, 0.6, 409, 1095.98, -470.06, -105.20, 3.9 }
inst5level = { 55, 57, 58, 58, 58, 58 }

-- instance min level 60+
raid = { "Naxxramas (Raid 60+)", "Le Repaire d\'Onyxia (Raid 60+)", "Zul'Gurub (Raid 60+)", "Le temple d\'Ahn\'Qiraj (Raid 60+)" , "Les Ruines d'Ahn\'Qiraj (Raid 60+)"}
if lng == "EN" then raid = { "Naxxramas (Raid 60+)", "Onyxia\'s Lair (Raid 60+)", "Zul'Gurub (Raid 60+)", "The Temple of Ahn\'Qiraj (Raid 60+)" , "The Ruins of Ahn\'Qiraj (Raid 60+)"} end
if lng == "DE" then raid = { "Naxxramas (Raid 60+)", "Onyxias Hort (Raid 60+)", "Zul'Gurub (Raid 60+)", "Tempel von Ahn\'Qiraj (Raid 60+)" , "Ruinen von Ahn\'Qiraj (Raid 60+)"} end
raidcoord = { 533, 3006.32, -3406.93, 299.15, 4.66, 249, 26.17, -68.26, -6.80, 4.77, 309, -11945.92, -1260.86, 85.37, 5.33, 531, -8205, 2025.81, 129.08, 1.2, 509, -8442.05, 1516.65, 31.93, 2.9 }
raidlevel = { 60, 60, 60, 60, 60 }

-- The big array for optimize the number of function :)
instance_a= { instance1, instance2, instance3, instance4, instance5, raid }
instlevel_a= { inst1level, inst2level, inst3level, inst4level, inst5level, raidlevel }
instcoord_a= { instcoord1, instcoord2, instcoord3, instcoord4, instcoord5, raidcoord }

-- NPC message
NOMONEY = "|cffff3333Tu n'as pas assez d\'or pour voyager|r"
if lng == "EN" then NOMONEY = "|cffff3333You must have more gold to travel|r" end
if lng == "DE" then NOMONEY = "|cffff3333Du brauchst mehr Gold zü reisen|r" end

NOLEVEL = "|cffff3333Tu n'as pas le niveau pour y aller|r"
if lng == "EN" then NOLEVEL = "|cffff3333You must have the min level for go there|r" end
if lng == "DE" then NOLEVEL = "|cffff3333Du brauchst das minimum level zü reisen|r" end

OK4TRAVEL = "|cff33ff33Bon voyage et bonne chance pour|r "
if lng == "EN" then OK4TRAVEL = "|cff33ff33Have a nice day, and good luck for|r " end
if lng == "DE" then OK4TRAVEL = "|cff33ff33Gute Reise und viel Glück für|r " end

-- Send the first menu (with the selections)

function My_Teleporter_GossipHello(player,_Creature)
    local i = 1
      while don_choice[i] do
        player:ADD_GOSSIP_ITEM( 0, don_choice[i]        , GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i )
        i = i + 1
      end
   player:SEND_GOSSIP_MENU(7499  ,_Creature:GetGUID());
   return RETURN_OK
end
-- Called when you chose an option

function My_Teleporter_GossipSelect(player, _Creature, sender, action)
  local menu= sender - GOSSIP_SENDER_INSTANCE
  if sender == GOSSIP_SENDER_MAIN then
     My_Teleporter_SendDefaultMenu(player, _Creature,  action)
  elseif sender == GOSSIP_SENDER_INSTANCE + menu then
     My_Teleporter_SendInstanceMenu(player, _Creature,  action, menu)
  end
return RETURN_OK
end

function My_Teleporter_SendDefaultMenu(player, _Creature,  action)
        local instance= action - GOSSIP_ACTION_INFO_DEF
        local minst= instance_a[instance]
        local i = 1
        if action == GOSSIP_ACTION_INFO_DEF + instance then
          while minst[i] do
                player:ADD_GOSSIP_ITEM( instance, minst[i]        , GOSSIP_SENDER_INSTANCE + instance, GOSSIP_ACTION_INFO_DEF + i )
                i = i + 1
          end
        player:SEND_GOSSIP_MENU(7499,_Creature:GetGUID())
        end
return RETURN_OK
end

-- Check player (money and level and GM)
function My_Teleporter_CheckPlayer(player,_Creature,action,nlevel)
      travelok = 0
      -- Game master don t pay
      if (player:GetSecurity() > 0 ) then
        travelok = 1
      else
      --level value
      local playlevel = player:getLevel()
      local levelok = playlevel - nlevel
        if levelok > -1 then
          local money = player:GetMoney()
          local prix = price[action]
          local cout = ( money - prix )
          if cout >= 0 then
           player:SetMoney(cout);
           travelok = 1
          else
            player:getSelectedCreature():MonsterSay(NOMONEY, 1);
          end
        else
            player:getSelectedCreature():MonsterSay(NOLEVEL, 1);
        end
      end
  return travelok
end

function My_Teleporter_SendInstanceMenu(player, _Creature,  action, instance)
-- Create the variable choice
        local minst= instance_a[instance]
        local linst= instlevel_a[instance]
        local cinst= instcoord_a[instance]
-- Continue...
         local i = 1
         while minst[i] do i = i + 1 end
-- Check if the player can travel
         if action < GOSSIP_ACTION_INFO_DEF + i then
            local nlevel = action - GOSSIP_ACTION_INFO_DEF
            My_Teleporter_CheckPlayer(player,_Creature,instance,linst[nlevel]);
         end
         if travelok == 1 then
            local action = action - GOSSIP_ACTION_INFO_DEF
            local c_min= ((action * 5) - 4)
            player:getSelectedCreature():MonsterSay(OK4TRAVEL..minst[action], 1);
            player:TeleportTo( cinst[c_min], cinst[c_min + 1], cinst[c_min + 2], cinst[c_min + 3], cinst[c_min + 4], true, true );
         end
         return RETURN_OK
end

-- Assign the functions
My_Teleporter.GossipHello = My_Teleporter_GossipHello;
My_Teleporter.GossipSelect= My_Teleporter_GossipSelect;

-- Activate (run) the script
My_Teleporter:Activate();