When a player gets eliminated I want to remove that player from the AllPlayers array and remove the same index from the box array and dispose of that box.
1 Like
I haven’t tested this but It should logically be able to do what you want to achieve. And Instead of playing with indexes, it uses a map that essentially “attaches” the player/agent to that specific prop. (Think like an array but instead of having indexes the player itself is the index and then gets the creative_prop)
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
game_manager:=class(creative_device):
@editable var AvailableBlocks : []creative_prop = array{}
var AgentsBlock : [agent]creative_prop = map{}
OnBegin<override>()<suspends>:void=
for(Player:GetPlayspace().GetPlayers()):
if(FC:=Player.GetFortCharacter[]):
FC.EliminatedEvent().Subscribe(PlayerEliminated1)
if(Block:=AvailableBlocks[0]):
if(set AgentsBlock[Player]=Block):
Print("Block assigned to player")
if(ArrayWithoutCurrentBlock:=AvailableBlocks.RemoveElement[0]):
set AvailableBlocks=ArrayWithoutCurrentBlock
PlayerEliminated1(ElimResult:elimination_result):void=
if(Agent:=ElimResult.EliminatedCharacter.GetAgent[]):
if(Block:=AgentsBlock[Agent]):
Block.Dispose()