Advertisement
Guest User

Grandelf

a guest
Dec 31st, 2009
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.29 KB | None | 0 0
  1. --[[
  2.  
  3.     Tent chat command
  4.     Scripted by Grandelf
  5.         Version 2
  6.        
  7. ]]--
  8.  
  9.  
  10. TENT = {}
  11.  
  12. TENT.GO = 180039            -- GameObject ID of the tent
  13.  
  14. TENT.Spawn = "#tent spawn"
  15. TENT.Delete = "#tent delete"
  16. TENT.Activate = "#tent activate"
  17. TENT.Deactivate = "#tent deactivate"
  18. TENT.Count = "#tent count"
  19. TENT.Port = "#tent port"
  20. TENT.PLRPORT = "#tent playerport"
  21. TENT.ENTERPASS = "#tent pass"
  22. TENT.SETPASS = "#tent setpass"
  23.  
  24. TENT.PortAllowed = true         -- Put false, if you want to turn off the option that players can port to their tent.
  25.  
  26. TENT.FORBIDDENZONES = {             -- You can just add zone by putting them beneath the last one, like I did.
  27.     2257, -- Deep Run Tram
  28.     1537, -- Ironforge
  29.     1519, -- Stormwind City
  30.     3557, -- The Exodar
  31.     1657, -- Darnassus
  32.     4395, -- Dalaran
  33.     3703, -- Shattrath City
  34.     2597, -- Alterac Valley
  35.     3358, -- Arathi Basin
  36.     3820, -- Eye of the Storm
  37.     4710, -- Isle of Conquest
  38.     3702, -- The Circle of Blood
  39.     3698, -- The Ring of Trials
  40.     4406, -- The Ring of Valor
  41.     3277, -- Warsong Gulch
  42.     4197, -- Wintergrasp
  43.     1637, -- Orgrimmar
  44.     3487, -- Silvermoon City
  45.     1638, -- Thunderbluff
  46.     1497, -- Undercity
  47. }  
  48.  
  49. --[[
  50.  
  51.         Do not edit below here unless you know what you're doing.
  52.  
  53. ]]--
  54.  
  55. TENT.Activated = true
  56. TENT.TentCount = 0
  57.  
  58. function TENT.TentSystem(event, player, message, type, language)
  59.     if (message == TENT.Spawn) then
  60.         if (TENT.Activated == true) then
  61.             if (player:GetInstanceID() == nil) then
  62.                 if (TENT.ZoneCheck(player) == true) then
  63.                     if (TENT[player:GetName()] == nil) then
  64.                         TENT[player:GetName()] = {}
  65.                         TENT[player:GetName()].HasTent = 1
  66.                         TENT[player:GetName()].Map = player:GetMapId()
  67.                         TENT[player:GetName()].PosX = player:GetX()
  68.                         TENT[player:GetName()].PosY = player:GetY()
  69.                         TENT[player:GetName()].PosZ = player:GetZ()
  70.                         player:SpawnGameObject(TENT.GO, player:GetX(), player:GetY(), player:GetZ(), player:GetO(), 0)
  71.                         TENT.TentCount = TENT.TentCount + 1
  72.                     elseif (TENT[player:GetName()].HasTent == 0) then
  73.                         TENT[player:GetName()].HasTent = 1
  74.                         TENT[player:GetName()].PosX = player:GetX()
  75.                         TENT[player:GetName()].Map = player:GetMapId()
  76.                         TENT[player:GetName()].PosX = player:GetX()
  77.                         TENT[player:GetName()].PosY = player:GetY()
  78.                         TENT[player:GetName()].PosZ = player:GetZ()
  79.                         player:SpawnGameObject(TENT.GO, player:GetX(), player:GetY(), player:GetZ(), player:GetO(), 0)
  80.                         TENT.TentCount = TENT.TentCount + 1
  81.                     else
  82.                         player:SendBroadcastMessage("You already have a tent")
  83.                     end
  84.                 else
  85.                     player:SendBroadcastMessage("You cannot spawn a tent in this zone.")
  86.                 end
  87.             else
  88.                 player:SendBroadcastMessage("You cannot spawn a tent in an instance.")
  89.             end
  90.         else
  91.             player:SendBroadcastMessage("You cannot spawn a tent at this moment, you have to wait for a GM to put this option on again.")
  92.         end
  93.         return 0
  94.     end
  95.     if (message == TENT.Delete) then
  96.         if (TENT[player:GetName()] == nil) then
  97.             player:SendBroadcastMessage("You do not have a tent.")
  98.         elseif (TENT[player:GetName()].HasTent == 1) then
  99.             local PLRTENT = TENT.TentCheck(player)
  100.             if (PLRTENT ~= nil) then
  101.                 TENT[player:GetName()].HasTent = 0
  102.                 PLRTENT:Despawn(1000, 0)
  103.                 TENT.TentCount = TENT.TentCount - 1
  104.                 TENT[player:GetName()].Password = nil
  105.             else
  106.                 player:SendBroadcastMessage("You have to be near your tent, in order to delete it.")
  107.             end
  108.         else
  109.             player:SendBroadcastMessage("You do not have a tent.")
  110.         end
  111.         return 0
  112.     end
  113.     if (message == TENT.Activate) then
  114.         if (player:CanUseCommand("a") == true) then
  115.             if (TENT.Activated == false) then
  116.                 TENT.Activated = true
  117.                 local plrs = GetPlayersInWorld()
  118.                 for k, v in pairs(plrs) do
  119.                     v:SendBroadcastMessage("|cffff0000[Tent System]: |cFFFFFF00 The tent system got enabled by "..player:GetName()..".")
  120.                 end
  121.             else
  122.                 player:SendBroadcastMessage("The tent system is already enabled.")
  123.             end
  124.         return 0
  125.         end
  126.     end
  127.     if (message == TENT.Deactivate) then
  128.         if (player:CanUseCommand("a") == true) then
  129.             if (TENT.Activated == true) then
  130.                 TENT.Activated = false
  131.                 local plrs = GetPlayersInWorld()
  132.                 for k, v in pairs(plrs) do
  133.                     v:SendBroadcastMessage("|cffff0000[Tent System]: |cFFFFFF00 The tent system got disabled by "..player:GetName()..".")
  134.                 end
  135.             else
  136.                 player:SendBroadcastMessage("The tent system is already disabled.")
  137.             end
  138.         return 0
  139.         end
  140.     end
  141.     if (message == TENT.Count) then
  142.         if (player:CanUseCommand("a") == true) then
  143.             if (TENT.TentCount == 0) then
  144.                 player:SendBroadcastMessage("There are no tents spawned")
  145.             elseif (TENT.TentCount == 1) then
  146.                 player:SendBroadcastMessage("There is 1 tent spawned.")
  147.             else   
  148.                 player:SendBroadcastMessage("There are "..TENT.TentCount.." tents spawned.")
  149.             end
  150.         end
  151.         return 0   
  152.     end
  153.     if (message == TENT.Port) then
  154.         if (TENT.PortAllowed == true) then
  155.             if (TENT[player:GetName()] == nil) then
  156.                 player:SendBroadcastMessage("You do not have a tent.")
  157.             elseif (TENT[player:GetName()].HasTent == 1) then
  158.                 if (player:IsInCombat() == false) then
  159.                     if (player:IsFFAPvPFlagged() == false) then
  160.                         player:Teleport(TENT[player:GetName()].Map, TENT[player:GetName()].PosX, TENT[player:GetName()].PosY, TENT[player:GetName()].PosZ)
  161.                     else
  162.                         player:SendBroadcastMessage("You cannot use this when you are FFA flagged.")
  163.                     end
  164.                 else       
  165.                     player:SendBroadcastMessage("You cannot use this while in combat.")
  166.                 end
  167.             else
  168.                 player:SendBroadcastMessage("You do not have a tent.")
  169.             end
  170.         else
  171.             return 0
  172.         end
  173.         return 0
  174.     end
  175.     if (message:find(TENT.PLRPORT.." ") == 1) then
  176.         local T = message:gsub(TENT.PLRPORT.." ", "")
  177.         local TNAME = TENT[T]
  178.         if (TNAME.HasTent == 1) then
  179.             if (TNAME.Password == nil) then
  180.                 player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
  181.             else
  182.                 if (TENT[player:GetName()] == nil) then
  183.                     TENT[player:GetName()] = {}
  184.                     TENT[player:GetName()].Tries = 3
  185.                     player:SendBroadcastMessage("This player is using a password. Type #tent pass password, to teleport to the tent.")
  186.                     TENT[player:GetName()].CanUseComand = 1
  187.                     TENT[player:GetName()].TeleTarget = T
  188.                 else   
  189.                     player:SendBroadcastMessage("This player is using a password. Type #tent pass password, to teleport to the tent.")
  190.                     TENT[player:GetName()].Tries = 3
  191.                     TENT[player:GetName()].CanUseComand = 1
  192.                     TENT[player:GetName()].TeleTarget = T
  193.                 end
  194.             end
  195.         else
  196.             player:SendBroadcastMessage("This player does not have a tent.")
  197.         end
  198.         return 0
  199.     end
  200.     if (message:find(TENT.ENTERPASS.." ") == 1) then
  201.         if (TENT[player:GetName()] == nil) then
  202.             TENT[player:GetName()] = {}
  203.             if (TENT[player:GetName()].CanUseComand == 1) then
  204.                 local T = TENT[player:GetName()].TeleTarget
  205.                 local TNAME = TENT[T]
  206.                 local Pass = message:gsub(TENT.ENTERPASS.." ", "")
  207.                 if (Pass == TNAME.Password) then
  208.                     player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
  209.                     TENT[player:GetName()].CanUseComand = 0
  210.                 else
  211.                     if (TENT[player:GetName()].Tries == nil) then
  212.                         TENT[player:GetName()].Tries = 2
  213.                         player:SendBroadcastMessage("The password you entered is not correct. You can try it "..TENT[player:GetName()].Tries.." more times. After that you have to re-enter the "..TENT.PLRPORT.." command.")
  214.                     else   
  215.                         TENT[player:GetName()].Tries = TENT[player:GetName()].Tries - 1
  216.                         if (TENT[player:GetName()].Tries ~= 0) then
  217.                             player:SendBroadcastMessage("The password you entered is not correct. You can try it "..TENT[player:GetName()].Tries.." more times. After that you have to re-enter the "..TENT.PLRPORT.." command.")
  218.                         else
  219.                             player:SendBroadcastMessage("You have to re-enter "..TENT.PLRPORT.."")
  220.                             TENT[player:GetName()].CanUseComand = 0
  221.                         end
  222.                     end
  223.                 end
  224.             else
  225.                 player:SendBroadcastMessage("You can only use this after trying to teleport to another player's tent which is using a password.")
  226.             end
  227.             return 0
  228.         end
  229.         if (TENT[player:GetName()].CanUseComand == 1) then
  230.             local T = TENT[player:GetName()].TeleTarget
  231.             local TNAME = TENT[T]
  232.             local Pass = message:gsub(TENT.ENTERPASS.." ", "")
  233.             if (Pass == TNAME.Password) then
  234.                 player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
  235.                 TENT[player:GetName()].CanUseComand = 0
  236.             else
  237.                 if (TENT[player:GetName()].Tries == nil) then
  238.                     TENT[player:GetName()].Tries = 2
  239.                     player:SendBroadcastMessage("The password you entered is not correct. You can try it "..TENT[player:GetName()].Tries.." more times. After that you have to re-enter the "..TENT.PLRPORT.." command.")
  240.                 else   
  241.                     TENT[player:GetName()].Tries = TENT[player:GetName()].Tries - 1
  242.                     if (TENT[player:GetName()].Tries ~= 0) then
  243.                         player:SendBroadcastMessage("The password you entered is not correct. You can try it "..TENT[player:GetName()].Tries.." more times. After that you have to re-enter the "..TENT.PLRPORT.." command.")
  244.                     else
  245.                         player:SendBroadcastMessage("You have to re-enter "..TENT.PLRPORT.."")
  246.                         TENT[player:GetName()].CanUseComand = 0
  247.                     end
  248.                 end
  249.             end
  250.         else
  251.             player:SendBroadcastMessage("You can only use this after trying to teleport to another player's tent which is using a password.")
  252.         end
  253.         return 0
  254.     end
  255.     if (message:find(TENT.SETPASS.." ") == 1) then
  256.         local Pass = message:gsub(TENT.ENTERPASS.." ", "") 
  257.         local Passw = string.sub(Pass, 15)
  258.         if (TENT[player:GetName()] ~= nil) then
  259.             if (TENT[player:GetName()].Password == nil) then
  260.                 TENT[player:GetName()].Password = Passw
  261.                 player:SendBroadcastMessage("You succesfully set your password to "..TENT[player:GetName()].Password.."")
  262.             else
  263.                 TENT[player:GetName()].Password = nil
  264.                 TENT[player:GetName()].Password = Passw
  265.                 player:SendBroadcastMessage("You succesfully changed your password to "..TENT[player:GetName()].Password.."")
  266.             end
  267.         else
  268.             player:SendBroadcastMessage("You do not have a tent.")
  269.         end
  270.     return 0   
  271.     end    
  272. end        
  273.    
  274. function TENT.TentCheck(player)
  275.     local GameObjects = player:GetInRangeObjects()
  276.     for k, v in pairs(GameObjects) do
  277.         if (TENT[player:GetName()].PosX == v:GetX()) then
  278.             return v
  279.         end
  280.     end
  281. end
  282.  
  283. function TENT.ZoneCheck(player)
  284.     for k, v in pairs(TENT.FORBIDDENZONES) do
  285.         if (player:GetZoneId() ~= v) then
  286.             return true
  287.         else
  288.             return false
  289.         end
  290.     end
  291. end
  292.  
  293. RegisterServerHook(16, "TENT.TentSystem")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement