Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- v2.3 -
- IS = {InstanceIDs = {44}, -- Maintable
- InstanceActivated = {},
- Spawned = {},
- PlayerCount = {},
- pCheck = {},
- CountD = {}}
- function IS.EnterInstance(_,Player)
- Player:RegisterLuaEvent(function() -- whole script timed for error elimination (Player is not in world until teleportet?)
- local AreaTriggerID = Player:GetMapId()
- local AreaCheck = 0
- local iID = Player:GetInstanceID()
- for nr,inID in pairs(IS.InstanceIDs) do -- check if mapid is in IS.InstanceIDs
- if AreaTriggerID==inID then
- AreaCheck = 1
- if iID and IS.InstanceActivated[iID] and IS.Spawned[iID] then -- health correction
- if IS.PlayerCount[iID] then
- local plrCount = GetInstancePlayerCount(AreaTriggerID, iID)
- if IS.PlayerCount[iID] ~= plrCount and plrCount >=1 then
- for uNr, unt in pairs(IS.Spawned[iID]) do
- if type(unt)=="table" then
- unt[1]:SetMaxHealth( unt[1]:GetMaxHealth() * plrCount )
- end
- end
- IS.PlayerCount[iID] = plrCount
- end
- else
- IS.PlayerCount[iID] = GetInstancePlayerCount(AreaTriggerID, iID)
- if IS.PlayerCount[iID] > 1 then
- for uNr, unt in pairs(IS.Spawned[iID]) do
- if type(unt)=="table" then
- unt[1]:SetMaxHealth( unt[1]:GetMaxHealth() * IS.PlayerCount[iID] )
- end
- end
- end
- end
- end
- end
- end
- if AreaCheck==0 then return; end -- if mapid is not in it, cancel further actions
- local pGUID = tostring(Player:GetGUID())
- if not IS.InstanceActivated[iID] then
- Player:RegisterLuaEvent(function() Player:CastSpell(59123) end, 200,1)
- IS.Info = CreateFrame("Information")
- IS.IB = IS.Info:CreateTextBox("InfoBox")
- -------------------------
- IS.Info:SetHeight(75)
- IS.Info:SetYOffset(0)
- IS.Info:SetWidth(300)
- IS.Info:SetCantMove(true)
- IS.Info:SetCantClose(true)
- -------------------------
- IS.IB:SetYOffset(-20)
- IS.IB:SetWidth(300)
- IS.IB:SetHeight(300)
- IS.IB:SetText("")
- -------------------------
- IS.Info:Send(Player)
- --------------------------------------------------
- --------------------------------------------------
- IS.Diff = CreateFrame("Difficulty")
- IS.Stat = IS.Diff:CreateStatusBar("Countdown")
- IS.Easy = IS.Diff:CreateButton("Easy")
- IS.Ie = IS.Diff:CreateButton("InfoEasy")
- IS.Medium = IS.Diff:CreateButton("Medium")
- IS.Im = IS.Diff:CreateButton("InfoMedium")
- IS.Hard = IS.Diff:CreateButton("Hard")
- IS.Ih = IS.Diff:CreateButton("InfoHard")
- -------------------------
- IS.Stat:SetWidth(250)
- IS.Stat:SetHeight(5)
- IS.Stat:SetYOffset(25)
- IS.Stat:SetXOffset(-10)
- IS.Stat:SetCountdown(38)
- -------------------------
- IS.Diff:SetHeight(75)
- IS.Diff:SetWidth(300)
- IS.Diff:SetCantMove(true)
- IS.Diff:SetCantClose(true)
- -------------------------
- IS.Easy:SetText("Easy")
- IS.Easy:SetXOffset(-100)
- IS.Easy:SetYOffset(5)
- IS.Easy:SetWidth(80)
- IS.Easy:SetHeight(35)
- IS.Easy:SetEvent("OnClick", function(self, event, player,_)
- IS.Diff:Hide(player)
- IS.Info:Hide(player)
- player:RemoveAura(59123)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.StartSpawning(player,AreaTriggerID,1)
- end)
- -------------------------
- IS.Medium:SetText("Medium")
- IS.Medium:SetXOffset(-10)
- IS.Medium:SetYOffset(5)
- IS.Medium:SetWidth(80)
- IS.Medium:SetHeight(35)
- IS.Medium:SetEvent("OnClick", function(self, event, player,_)
- IS.Diff:Hide(player)
- IS.Info:Hide(player)
- player:RemoveAura(59123)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.StartSpawning(player,AreaTriggerID,2)
- end)
- -------------------------
- IS.Hard:SetText("Hard")
- IS.Hard:SetXOffset(80)
- IS.Hard:SetYOffset(5)
- IS.Hard:SetWidth(80)
- IS.Hard:SetHeight(35)
- IS.Hard:SetEvent("OnClick", function(self, event, player,_)
- IS.Diff:Hide(player)
- IS.Info:Hide(player)
- player:RemoveAura(59123)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.StartSpawning(player,AreaTriggerID,4)
- end)
- -------------------------
- -------------------------
- IS.pCheck[pGUID] = {0,0,0}
- IS.Ie:SetText("\\/")
- IS.Ie:SetXOffset(-100)
- IS.Ie:SetYOffset(-17)
- IS.Ie:SetWidth(20)
- IS.Ie:SetHeight(20)
- IS.Ie:SetEvent("OnClick", function(self, event, player,_)
- IS.Info:Hide(player)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.CountD[pGUID] = 30
- LCF:RegisterLuaEvent(tostring(player),IS.Countdowner,1000,30, player,IS.Diff,IS.Info)
- if IS.pCheck[pGUID][1]==0 then
- IS.Ie:SetText("/\\")
- IS.Im:SetText("\\/")
- IS.Ih:SetText("\\/")
- IS.Info:SetHeight(300)
- IS.Info:SetYOffset(-113)
- IS.IB:SetText("|cFF58FF0A--EASY--|r\n\n\nIf you choose the difficulty\nLevel 'Easy' you will get this:\n\n|cFF58FF0A1xBoss-Loot|r")
- IS.pCheck[pGUID][1] = 1
- IS.pCheck[pGUID][2] = 0
- IS.pCheck[pGUID][3] = 0
- else
- IS.Ie:SetText("\\/")
- IS.IB:SetText("")
- IS.Info:SetHeight(75)
- IS.Info:SetYOffset(0)
- IS.pCheck[pGUID][1] = 0
- end
- IS.Info:Send(Player)
- IS.Diff:Send(Player)
- end)
- -------------------------
- IS.Im:SetText("\\/")
- IS.Im:SetXOffset(-10)
- IS.Im:SetYOffset(-17)
- IS.Im:SetWidth(20)
- IS.Im:SetHeight(20)
- IS.Im:SetEvent("OnClick", function(self, event, player,_)
- IS.Info:Hide(player)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.CountD[pGUID] = 30
- LCF:RegisterLuaEvent(tostring(player),IS.Countdowner,1000,30, player,IS.Diff,IS.Info)
- if IS.pCheck[pGUID][2]==0 then
- IS.Ie:SetText("\\/")
- IS.Im:SetText("/\\")
- IS.Ih:SetText("\\/")
- IS.Info:SetHeight(300)
- IS.Info:SetYOffset(-113)
- IS.IB:SetText("|cFFFF8D0A--MEDIUM--|r\n\n\nIf you choose the difficulty\nLevel 'Medium' you will get this:\n\n|cFFFF8D0A2xBoss-Loot\n1xRandom-Enchantment|r")
- IS.pCheck[pGUID][1] = 0
- IS.pCheck[pGUID][2] = 1
- IS.pCheck[pGUID][3] = 0
- else
- IS.Im:SetText("\\/")
- IS.IB:SetText("")
- IS.Info:SetHeight(75)
- IS.Info:SetYOffset(0)
- IS.pCheck[pGUID][2] = 0
- end
- IS.Info:Send(Player)
- IS.Diff:Send(Player)
- end)
- -------------------------
- IS.Ih:SetText("\\/")
- IS.Ih:SetXOffset(80)
- IS.Ih:SetYOffset(-17)
- IS.Ih:SetWidth(20)
- IS.Ih:SetHeight(20)
- IS.Ih:SetEvent("OnClick", function(self, event, player,_)
- IS.Info:Hide(player)
- player:RemoveLuaEvent(IS.Countdowner)
- IS.CountD[pGUID] = 30
- LCF:RegisterLuaEvent(tostring(player),IS.Countdowner,1000,30, player,IS.Diff,IS.Info)
- if IS.pCheck[pGUID][3]==0 then
- IS.Ie:SetText("\\/")
- IS.Im:SetText("\\/")
- IS.Ih:SetText("/\\")
- IS.Info:SetHeight(300)
- IS.Info:SetYOffset(-113)
- IS.IB:SetText("|cFFFF0000--HARD--|r\n\n\nIf you choose the difficulty\nLevel 'Hard' you will get this:\n\n|cFFFF8D0A2xBoss-Loot\n1xRandom-Enchantment|r\n|cFFFF00001xSecret-Boss|r")
- IS.pCheck[pGUID][1] = 0
- IS.pCheck[pGUID][2] = 0
- IS.pCheck[pGUID][3] = 1
- else
- IS.Ih:SetText("\\/")
- IS.IB:SetText("")
- IS.Info:SetHeight(75)
- IS.Info:SetYOffset(0)
- IS.pCheck[pGUID][3] = 0
- end
- IS.Info:Send(Player)
- IS.Diff:Send(Player)
- end)
- -------------------------
- IS.Diff:Send(Player)
- IS.CountD[pGUID] = 30
- LCF:RegisterLuaEvent(tostring(Player),IS.Countdowner,30000,1, Player,IS.Diff,IS.Info)
- end end, 100, 1)
- end
- function IS.Countdowner(Plr,Diff,Info)
- local pGUID = tostring(Plr:GetGUID())
- IS.CountD[pGUID] = IS.CountD[pGUID]-1
- if IS.CountD[pGUID]==0 then
- for nr,inID in pairs(IS.InstanceIDs) do
- if Plr:GetMapId()==inID then
- Plr:RemoveAura(59123)
- Plr:Teleport(-7553.146,-1203.9,478.05,5.317)
- Diff:Hide(Plr)
- Info:Hide(Plr)
- end
- end
- end
- end
- RegisterServerHook(4, IS.EnterInstance)
- for iniint,iniid in pairs(IS.InstanceIDs) do
- RegisterInstanceEvent(iniid, 6, function(InstanceID) IS.InstanceActivated[InstanceID] = true; end)
- end
- function IS.StartSpawning(Player,AreaTriggerID,Difficulty)
- local iID = Player:GetInstanceID()
- IS.Spawned[iID] = {Difficulty}
- local NPC_EASY = nil; local NPC_MEDI = nil; local NPC_HARD = nil; local NPC_DEBUG = nil;
- if Difficulty==1 then
- NPC_EASY = WorldDBQuery("SELECT * FROM instance_spawns WHERE mapid = "..AreaTriggerID.." AND difficulty = 1 OR difficulty = 3 OR difficulty = 5 OR difficulty = 7;")
- elseif Difficulty==2 then
- NPC_MEDI = WorldDBQuery("SELECT * FROM instance_spawns WHERE mapid = "..AreaTriggerID.." AND difficulty = 2 OR difficulty = 3 OR difficulty = 6 OR difficulty = 7;")
- elseif Difficulty==4 then
- NPC_HARD = WorldDBQuery("SELECT * FROM instance_spawns WHERE mapid = "..AreaTriggerID.." AND difficulty = 4 OR difficulty = 5 OR difficulty = 6 OR difficulty = 7;")
- end
- if NPC_EASY and Difficulty==1 then
- IS.Spawning(Player, NPC_EASY, iID)
- elseif NPC_MEDI and Difficulty==2 then
- IS.Spawning(Player, NPC_MEDI, iID)
- elseif NPC_HARD and Difficulty==4 then
- IS.Spawning(Player, NPC_HARD, iID)
- end
- end
- function IS.Spawning(Player, SQL, iID)
- local Group_Version = {}
- repeat
- local grpid = SQL:GetColumn(8):GetULong()
- if Group_Version[grpid]==nil then
- local GVer = WorldDBQuery("SELECT versionid FROM instance_spawns WHERE groupid = "..grpid..";")
- local maxVersion = nil
- repeat
- local GVnum = GVer:GetColumn(0):GetULong()
- if maxVersion then
- if maxVersion<GVnum then
- maxVersion = GVnum
- end
- else
- maxVersion = GVnum
- end
- until GVer:NextRow()~=true
- Group_Version[grpid] = math.random(1, maxVersion)
- end
- if Group_Version[grpid]==SQL:GetColumn(9):GetULong() then
- local spwn = Player:SpawnCreature(SQL:GetColumn(1):GetULong(), SQL:GetColumn(3):GetFloat(), SQL:GetColumn(4):GetFloat(), SQL:GetColumn(5):GetFloat(), SQL:GetColumn(6):GetFloat(), SQL:GetColumn(7):GetULong(),0, SQL:GetColumn(10):GetULong(), SQL:GetColumn(11):GetULong(), SQL:GetColumn(12):GetULong(),_,_)
- table.insert(IS.Spawned[iID], {spwn,grpid})
- end
- until SQL:NextRow()~=true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement