Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --PLACE THIS ONLY ON A SPECIAL VERSION OF THE MAP WHICH NEEDS IT
- --THE FIRST VARIABLE SPECIFIES HOW MANY SECONDS PASSES
- --FROM THE START OF A LEVEL BEFORE NEW PLAYERS GET SPAWNED
- --NEAR OTHER PLAYERS. BEFORE THAT TIME PASSES, NEW PLAYERS
- --ARE SPAWNED AT ONE OF THE TACTIC MARKERS
- --YOU SHOULD SELECT AND ASSIGN ALL YOUR TACTIC MARKERS TO THE VARIABLE
- --"SpawnMarkers", AND ASSIGN THE CHAPTER AFTER WHICH PLAYERS ARE TOGETHER
- --TO THE "JointChapter"
- local fTimeBeforePlayerSpawnedNearAnotherPlayer = 10
- local ArrayOfStuffYouHaveToAssign = {
- SpawnMarkers,
- JointChapter,
- }
- while not worldInfo:IsWarmupFinished() do
- Wait(CustomEvent("OnStep"))
- end
- local time = GetDateTimeLocal()
- local seed = 3600*tonumber(string.sub(time,-8,-7))+60*tonumber(string.sub(time,-5,-4))+tonumber(string.sub(time,-2,-1))
- local RNG = CreateRandomNumberGenerator(seed + mthTruncF(mthRndF() * 1000))
- local RndL = function(a,b)
- return (mthFloorF(RNG:RndF()*(b-a+1))%(b-a+1)+a)
- end
- local RealDeal = {}
- for i=1,#SpawnMarkers,1 do
- RealDeal[i] = SpawnMarkers[i]
- end
- local MixedMarkers = {}
- for i=1,#RealDeal,1 do
- local num = RndL(1,#SpawnMarkers-i+1)
- print(num)
- MixedMarkers[#MixedMarkers+1] = RealDeal[num]
- for j=num,#RealDeal,1 do
- RealDeal[j] = RealDeal[j+1]
- end
- end
- local IsPlayerHandled = {}
- local currMarker = 1
- local PlayerDyingSpot = {}
- local HandlePlayer = function(player)
- RunAsync(function()
- while not IsDeleted(player) do
- if not player:IsAlive() and (PlayerDyingSpot[player] == nil) then
- PlayerDyingSpot[player] = player:GetPlacement()
- end
- if player:IsAlive() and (PlayerDyingSpot[player] ~= nil) then
- player:SetPlacement(PlayerDyingSpot[player])
- PlayerDyingSpot[player] = nil
- end
- Wait(CustomEvent("OnStep"))
- end
- end)
- end
- local Players = worldInfo:GetAllPlayersInRange(worldInfo,10000)
- for i=1,#Players,1 do
- IsPlayerHandled[Players[i]] = true
- Players[i]:SetPlacement(MixedMarkers[currMarker]:GetPlacement())
- currMarker = currMarker % #MixedMarkers + 1
- HandlePlayer(Players[i])
- end
- local bSpawnOnMarkers = true
- RunHandled(function()
- Wait(Event(JointChapter.Started))
- end,
- On(Delay(fTimeBeforePlayerSpawnedNearAnotherPlayer)),
- function()
- bSpawnOnMarkers = false
- end,
- OnEvery(Event(worldInfo.PlayerBorn)),
- function(pay)
- local player = pay:GetBornPlayer()
- if not IsPlayerHandled[player] then
- if bSpawnOnMarkers then
- player:SetPlacement(MixedMarkers[currMarker]:GetPlacement())
- currMarker = currMarker % #MixedMarkers + 1
- else
- local bTeleported = false
- for pl,_ in pairs(IsPlayerHandled) do
- if (mthRndF() > 0.7) then
- player:SetPlacement(pl:GetPlacement())
- bTeleported = true
- end
- end
- if not bTeleported then
- for pl,_ in pairs(IsPlayerHandled) do
- player:SetPlacement(pl:GetPlacement())
- break
- end
- end
- end
- IsPlayerHandled[player] = true
- HandlePlayer(Players[i])
- end
- end
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement