I have been working on a small test code to make it so that when a player dies, they join the team of the player who kills them.
The issue is that the function to swap the team isn’t running when a player dies.
(The code was tested using the test players from the Fortnite creative debug menu.)
My current code is:
using { /Fortnite.com/Characters }
using { /Fortnite.com/UI }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Playspaces }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Game }
#hello
#hope this code is readable (:
#Made By RealMegaSteveYT//Megastevian
infectionMode := class(creative_device):
OnBegin<override>()<suspends>:void=
Print("test")
AllPlayers := GetPlayspace().GetPlayers()
for(Player:AllPlayers, FortCharacter:= Player.GetFortCharacter[]):
FortCharacter.EliminatedEvent().Subscribe(ElimManage) #problem is probably here
#a lot of parts are from the unreal engine forums because im just now starting with verse
ElimManage(Result:elimination_result):void=
Print("ElimManageStart") #this print does not run
TeamCollection := creative_device{}.GetPlayspace().GetTeamCollection()
eliminatedPlayer := Result.EliminatedCharacter
if:
killedAgent := eliminatedPlayer.GetAgent[]
killerChar := Result.EliminatingCharacter?
KillerAgent := killerChar.GetAgent[]
killerTeam := TeamCollection.GetTeam[KillerAgent]
Teams := TeamCollection.GetTeams()
killerTeamGet := TeamCollection.GetTeams().Find[killerTeam]
then:
Print("Death detected: commencing player check")
if(KillerAgent <> killedAgent):
Print("Death has been confirmed to be by other player")
AssignToTeamByIndex(killedAgent, killerTeamGet)
#megastevian
AssignToTeamByIndex(Agent: agent, Index:int):void=
TeamCollection := creative_device{}.GetPlayspace().GetTeamCollection()
Teams := TeamCollection.GetTeams()
if (
Team := Teams[Index]
TeamCollection.AddToTeam[Agent, Team]
)
then:
Print("Team assigned {Index}")
else:
Print("Could not assign team")
Sorry if the code is bad. I used a lot of info I got from the forums since I’m new to Verse and recently decided to try it out for this project after first using both Python and GDScript.