Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Tent chat command
- Scripted by Grandelf
- Version 2
- ]]--
- TENT = {}
- TENT.GO = 180039 -- GameObject ID of the tent
- TENT.Spawn = "#tent spawn"
- TENT.Delete = "#tent delete"
- TENT.Activate = "#tent activate"
- TENT.Deactivate = "#tent deactivate"
- TENT.Count = "#tent count"
- TENT.Port = "#tent port"
- TENT.PLRPORT = "#tent playerport"
- TENT.ENTERPASS = "#tent pass"
- TENT.SETPASS = "#tent setpass"
- TENT.PortAllowed = true -- Put false, if you want to turn off the option that players can port to their tent.
- TENT.FORBIDDENZONES = { -- You can just add zone by putting them beneath the last one, like I did.
- 2257, -- Deep Run Tram
- 1537, -- Ironforge
- 1519, -- Stormwind City
- 3557, -- The Exodar
- 1657, -- Darnassus
- 4395, -- Dalaran
- 3703, -- Shattrath City
- 2597, -- Alterac Valley
- 3358, -- Arathi Basin
- 3820, -- Eye of the Storm
- 4710, -- Isle of Conquest
- 3702, -- The Circle of Blood
- 3698, -- The Ring of Trials
- 4406, -- The Ring of Valor
- 3277, -- Warsong Gulch
- 4197, -- Wintergrasp
- 1637, -- Orgrimmar
- 3487, -- Silvermoon City
- 1638, -- Thunderbluff
- 1497, -- Undercity
- }
- --[[
- Do not edit below here unless you know what you're doing.
- ]]--
- TENT.Activated = true
- TENT.TentCount = 0
- function TENT.TentSystem(event, player, message, type, language)
- if (message == TENT.Spawn) then
- if (TENT.Activated == true) then
- if (player:GetInstanceID() == nil) then
- if (TENT.ZoneCheck(player) == true) then
- if (TENT[player:GetName()] == nil) then
- TENT[player:GetName()] = {}
- TENT[player:GetName()].HasTent = 1
- TENT[player:GetName()].Map = player:GetMapId()
- TENT[player:GetName()].PosX = player:GetX()
- TENT[player:GetName()].PosY = player:GetY()
- TENT[player:GetName()].PosZ = player:GetZ()
- player:SpawnGameObject(TENT.GO, player:GetX(), player:GetY(), player:GetZ(), player:GetO(), 0)
- TENT.TentCount = TENT.TentCount + 1
- elseif (TENT[player:GetName()].HasTent == 0) then
- TENT[player:GetName()].HasTent = 1
- TENT[player:GetName()].PosX = player:GetX()
- TENT[player:GetName()].Map = player:GetMapId()
- TENT[player:GetName()].PosX = player:GetX()
- TENT[player:GetName()].PosY = player:GetY()
- TENT[player:GetName()].PosZ = player:GetZ()
- player:SpawnGameObject(TENT.GO, player:GetX(), player:GetY(), player:GetZ(), player:GetO(), 0)
- TENT.TentCount = TENT.TentCount + 1
- else
- player:SendBroadcastMessage("You already have a tent")
- end
- else
- player:SendBroadcastMessage("You cannot spawn a tent in this zone.")
- end
- else
- player:SendBroadcastMessage("You cannot spawn a tent in an instance.")
- end
- else
- player:SendBroadcastMessage("You cannot spawn a tent at this moment, you have to wait for a GM to put this option on again.")
- end
- return 0
- end
- if (message == TENT.Delete) then
- if (TENT[player:GetName()] == nil) then
- player:SendBroadcastMessage("You do not have a tent.")
- elseif (TENT[player:GetName()].HasTent == 1) then
- local PLRTENT = TENT.TentCheck(player)
- if (PLRTENT ~= nil) then
- TENT[player:GetName()].HasTent = 0
- PLRTENT:Despawn(1000, 0)
- TENT.TentCount = TENT.TentCount - 1
- TENT[player:GetName()].Password = nil
- else
- player:SendBroadcastMessage("You have to be near your tent, in order to delete it.")
- end
- else
- player:SendBroadcastMessage("You do not have a tent.")
- end
- return 0
- end
- if (message == TENT.Activate) then
- if (player:CanUseCommand("a") == true) then
- if (TENT.Activated == false) then
- TENT.Activated = true
- local plrs = GetPlayersInWorld()
- for k, v in pairs(plrs) do
- v:SendBroadcastMessage("|cffff0000[Tent System]: |cFFFFFF00 The tent system got enabled by "..player:GetName()..".")
- end
- else
- player:SendBroadcastMessage("The tent system is already enabled.")
- end
- return 0
- end
- end
- if (message == TENT.Deactivate) then
- if (player:CanUseCommand("a") == true) then
- if (TENT.Activated == true) then
- TENT.Activated = false
- local plrs = GetPlayersInWorld()
- for k, v in pairs(plrs) do
- v:SendBroadcastMessage("|cffff0000[Tent System]: |cFFFFFF00 The tent system got disabled by "..player:GetName()..".")
- end
- else
- player:SendBroadcastMessage("The tent system is already disabled.")
- end
- return 0
- end
- end
- if (message == TENT.Count) then
- if (player:CanUseCommand("a") == true) then
- if (TENT.TentCount == 0) then
- player:SendBroadcastMessage("There are no tents spawned")
- elseif (TENT.TentCount == 1) then
- player:SendBroadcastMessage("There is 1 tent spawned.")
- else
- player:SendBroadcastMessage("There are "..TENT.TentCount.." tents spawned.")
- end
- end
- return 0
- end
- if (message == TENT.Port) then
- if (TENT.PortAllowed == true) then
- if (TENT[player:GetName()] == nil) then
- player:SendBroadcastMessage("You do not have a tent.")
- elseif (TENT[player:GetName()].HasTent == 1) then
- if (player:IsInCombat() == false) then
- if (player:IsFFAPvPFlagged() == false) then
- player:Teleport(TENT[player:GetName()].Map, TENT[player:GetName()].PosX, TENT[player:GetName()].PosY, TENT[player:GetName()].PosZ)
- else
- player:SendBroadcastMessage("You cannot use this when you are FFA flagged.")
- end
- else
- player:SendBroadcastMessage("You cannot use this while in combat.")
- end
- else
- player:SendBroadcastMessage("You do not have a tent.")
- end
- else
- return 0
- end
- return 0
- end
- if (message:find(TENT.PLRPORT.." ") == 1) then
- local T = message:gsub(TENT.PLRPORT.." ", "")
- local TNAME = TENT[T]
- if (TNAME.HasTent == 1) then
- if (TNAME.Password == nil) then
- player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
- else
- if (TENT[player:GetName()] == nil) then
- TENT[player:GetName()] = {}
- TENT[player:GetName()].Tries = 3
- player:SendBroadcastMessage("This player is using a password. Type #tent pass password, to teleport to the tent.")
- TENT[player:GetName()].CanUseComand = 1
- TENT[player:GetName()].TeleTarget = T
- else
- player:SendBroadcastMessage("This player is using a password. Type #tent pass password, to teleport to the tent.")
- TENT[player:GetName()].Tries = 3
- TENT[player:GetName()].CanUseComand = 1
- TENT[player:GetName()].TeleTarget = T
- end
- end
- else
- player:SendBroadcastMessage("This player does not have a tent.")
- end
- return 0
- end
- if (message:find(TENT.ENTERPASS.." ") == 1) then
- if (TENT[player:GetName()] == nil) then
- TENT[player:GetName()] = {}
- if (TENT[player:GetName()].CanUseComand == 1) then
- local T = TENT[player:GetName()].TeleTarget
- local TNAME = TENT[T]
- local Pass = message:gsub(TENT.ENTERPASS.." ", "")
- if (Pass == TNAME.Password) then
- player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
- TENT[player:GetName()].CanUseComand = 0
- else
- if (TENT[player:GetName()].Tries == nil) then
- TENT[player:GetName()].Tries = 2
- 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.")
- else
- TENT[player:GetName()].Tries = TENT[player:GetName()].Tries - 1
- if (TENT[player:GetName()].Tries ~= 0) then
- 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.")
- else
- player:SendBroadcastMessage("You have to re-enter "..TENT.PLRPORT.."")
- TENT[player:GetName()].CanUseComand = 0
- end
- end
- end
- else
- player:SendBroadcastMessage("You can only use this after trying to teleport to another player's tent which is using a password.")
- end
- return 0
- end
- if (TENT[player:GetName()].CanUseComand == 1) then
- local T = TENT[player:GetName()].TeleTarget
- local TNAME = TENT[T]
- local Pass = message:gsub(TENT.ENTERPASS.." ", "")
- if (Pass == TNAME.Password) then
- player:Teleport(TNAME.Map, TNAME.PosX, TNAME.PosY, TNAME.PosZ)
- TENT[player:GetName()].CanUseComand = 0
- else
- if (TENT[player:GetName()].Tries == nil) then
- TENT[player:GetName()].Tries = 2
- 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.")
- else
- TENT[player:GetName()].Tries = TENT[player:GetName()].Tries - 1
- if (TENT[player:GetName()].Tries ~= 0) then
- 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.")
- else
- player:SendBroadcastMessage("You have to re-enter "..TENT.PLRPORT.."")
- TENT[player:GetName()].CanUseComand = 0
- end
- end
- end
- else
- player:SendBroadcastMessage("You can only use this after trying to teleport to another player's tent which is using a password.")
- end
- return 0
- end
- if (message:find(TENT.SETPASS.." ") == 1) then
- local Pass = message:gsub(TENT.ENTERPASS.." ", "")
- local Passw = string.sub(Pass, 15)
- if (TENT[player:GetName()] ~= nil) then
- if (TENT[player:GetName()].Password == nil) then
- TENT[player:GetName()].Password = Passw
- player:SendBroadcastMessage("You succesfully set your password to "..TENT[player:GetName()].Password.."")
- else
- TENT[player:GetName()].Password = nil
- TENT[player:GetName()].Password = Passw
- player:SendBroadcastMessage("You succesfully changed your password to "..TENT[player:GetName()].Password.."")
- end
- else
- player:SendBroadcastMessage("You do not have a tent.")
- end
- return 0
- end
- end
- function TENT.TentCheck(player)
- local GameObjects = player:GetInRangeObjects()
- for k, v in pairs(GameObjects) do
- if (TENT[player:GetName()].PosX == v:GetX()) then
- return v
- end
- end
- end
- function TENT.ZoneCheck(player)
- for k, v in pairs(TENT.FORBIDDENZONES) do
- if (player:GetZoneId() ~= v) then
- return true
- else
- return false
- end
- end
- end
- RegisterServerHook(16, "TENT.TentSystem")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement