ideallyrob
(ideallyrob)
October 15, 2023, 9:15pm
1
New to verse, and doing the first project (gun game) in the documentation. However, this code is not making sense to me -
OnPlayerEliminated(Result:elimination_result):void=
Print("Player Eliminated")
EliminatingCharacter := Result.EliminatingCharacter
if (FortCharacter := EliminatingCharacter?, EliminationAgent := FortCharacter.GetAgent[]):
GrantNextWeapon(EliminationAgent)
Print("Player Promoted")
So when testing this on sentries it works fine, and I assume it works fine with players, however if a player dies in the environment (fall damage, lava, etc), they get promoted and both print statements print and I don’t understand why. Can someone please guide me on this. thanks!
You need to compare Result.EliminatedCharacter.GetAgent[] with EliminationAgent to avoid Self Eliminations
Also, you can take a look at this script, which is basically the gungame gamemode
1 Like
lol should read previous posts b4 i reply
tha anwser above is the way
1 Like
ideallyrob
(ideallyrob)
October 27, 2023, 4:12am
5
Here’s the updated code in-case anyone else is following the documentation:
OnPlayerEliminated(Result:elimination_result):void=
Print("Player Eliminated")
#EliminatingCharacter := Result.EliminatingCharacter
Eliminator := Result.EliminatingCharacter
Eliminated := Result.EliminatedCharacter
if (FortCharacter := Eliminator?, EliminatingAgent := FortCharacter.GetAgent[]):
if (Eliminated.GetAgent[] <> EliminatingAgent):
GrantNextWeapon(EliminatingAgent)
Print("PVP")
else:
Print("PVE")
1 Like
system
(system)
Closed
November 26, 2023, 4:13am
6
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.