I did this and it’s granting the item to the person who died every time they die even from fall damage how do I make it so it grants the gold to the person who killed them and no one gets gold if it’s from environment deaths? Thanks!
@editable
GoldGranter : item_granter_device = item_granter_device{}
OnPlayerEliminated(Result : elimination_result) : void =
Print("A Player was eliminated!")
EliminatingCharacter := Result.EliminatingCharacter
if (FortCharacter := EliminatingCharacter?):
if (EliminatingAgent := FortCharacter.GetAgent[]):
GoldGranter.GrantItem(EliminatingAgent)
OnBegin<override>()<suspends>:void=
AllPlayers := GetPlayspace().GetPlayers()
for (EliminationGamePlayer : AllPlayers):
if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
You can just check that EliminatingCharacter is different from EliminatedCharacter
It seems that for some reason, your character auto damages himself when falling or entering a damage volume for example. Which leads to a bug with damage amplifier devices btw.
I think you can do the code by yourself, but you can ask if you want.
This is untested, but I believe this is what I would do. I’m going purely on the documentation in Fortnite.digest.verse. Remember, you can Ctrl + Click on things in verse and it will take you to the definition.
@editable
GoldGranter : item_granter_device = item_granter_device{}
OnPlayerEliminated(Result : elimination_result) : void =
if(Result.EliminatingCharacter = false):
Print("Character dies from environement")
else if(Result.EliminatingCharacter = Result.EliminatedCharacter):
Print("Character dies from self weapon damage")
else if (FortCharacter := Result.EliminatingCharacter?, EliminatingAgent := FortCharacter.GetAgent[]):
Print("Character dies from other player")
GoldGranter.GrantItem(EliminatingAgent)
OnBegin<override>()<suspends>:void=
AllPlayers := GetPlayspace().GetPlayers()
for (EliminationGamePlayer : AllPlayers):
if (FortCharacter := EliminationGamePlayer.GetFortCharacter[]):
FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)