Hi,
I have this code that instantly respawns you and teleport to selected teleported. I wanted you make it teleport you to random teleporter from list. I created 2 lists using array and tried to shuffle through that list but I don’t know how my code should look.
InstantRespawn := class(creative_device):
respawnposition: vector3=vector3{X:= 250.00, Y:= 0.01, Z:= 161.9}
@editable
ElimMachine : elimination_manager_device = elimination_manager_device{}
@editable
TeleporterTeam1 : teleporter_device = teleporter_device{}
@editable
TeleporterTeam2 : teleporter_device = teleporter_device{}
NowRespawn(Agent: agent)<suspends>:void=
Sleep(0.1)
Agent.Respawn(respawnposition, rotation{})
TeleporterTeam1 .Teleport(Agent)
TeleporterTeam2 .Teleport(Agent)
SelfEliminated(Agent:agent):void=
spawn{NowRespawn(Agent)}
OnBegin<override>()<suspends>:void=
ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
4venzor
(4venzor)
February 17, 2025, 1:09am
2
InstantRespawn := class(creative_device):
respawnposition: vector3=vector3{X:= 250.00, Y:= 0.01, Z:= 161.9}
@editable
ElimMachine : elimination_manager_device = elimination_manager_device{}
@editable TeleportersTeam1 : []teleporter_device = array{}
@editable TeleportersTeam2 : []teleporter_device = array{}
NowRespawn(Agent: agent)<suspends>:void=
Sleep(0.1)
Agent.Respawn(respawnposition, rotation{})
Random := GetRandomInt(0,5)
if (Teleporter := TeleportersTeam1[Random]):
Teleporter.Teleport(Agent)
if (Teleporter := TeleportersTeam2[Random]):
Teleporter.Teleport(Agent)
SelfEliminated(Agent:agent):void=
spawn{NowRespawn(Agent)}
OnBegin<override>()<suspends>:void=
ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
Mineblo
(Mineblo)
February 17, 2025, 4:00am
3
The code seems correct, is your code not working at all or just asking for improvements?
Also I assume here ^ you have the actual teleporters device filted by team otherwise players will always spawn on team 2 teleporters
I found the problem with that code. It works fine when I get Eliminated but when I Eliminate it’s not working . It’s because there is no EliminationEvent in the code I think. What would be the best way to change that part of code so it works both when I get eliminated and eliminate?
OnBegin<override>()<suspends>:void=
ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
4venzor
(4venzor)
February 17, 2025, 7:35pm
5
If you want to teleport the player that did the Eliminating the Eliminated Event will not work since it only return’s the Agent that was Eliminated, to make it teleport the Agent that did the eliminating you could use → EliminationEvent
OnBegin<override>()<suspends>:void=
ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
ElimMachine.EliminationEvent.Subscribe()
I tried doing it before but I get this problem:
I changed “Agent” to “?Agent” but now I get this when I hover over “Agent” in this part of code:
spawn{NowRespawn(Agent)}
“This function parameter expects a value of type agent, but this argument is an incompatible value of type ?agent.(3509)”
Elimination(Agent:?agent):void=
spawn{NowRespawn(Agent)}
OnBegin<override>()<suspends>:void=
# ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
ElimMachine.EliminationEvent.Subscribe(Elimination)
4venzor
(4venzor)
February 18, 2025, 12:18am
7
This should fix that.
Elim(Agent : ?agent): void =
if (MaybeAgent := Agent?):
spawn{NowRespawn(MaybeAgent)}
OnBegin<override>()<suspends>:void=
ElimMachine.EliminatedEvent.Subscribe(SelfEliminated)
ElimMachine.EliminationEvent.Subscribe(Elim)