How to keep my gold coins after each teleportation in Verse ?

When i teleport my players to a receiving teleporter by using Verse, it seems they loose all their coins…
But they don’t loose their coins when players are entering a teleporter (without Verse instructions)

Thank you for your help.

Hi UNREG, can you show your code ? Also make sure there’s no Direct Binding done inside UEFN with these devices ?

1 Like

Hey frero ! ahah

Here is my code :

EndRound1(TeleportedAgent: agent)<suspends> : void =
            # Calculer le seuil à atteindre
var ThresholdToReach: float = AllPlayersCount * 2.0
var PlayersTeleported1:float = PlayersTeleported * 1.0
var AllPlayers : []agent = GetPlayspace().GetPlayers()
var NonQualifiedPlayers : []player = array{}
            
if (PlayersTeleported1 >= ThresholdToReach):   
# Afficher le message HUD
   HUDMessageDevice.Show()
   TeleportDrop2.Disable()
   Sleep(7.0)  # Pause pour permettre au message d'être affiché
   set AllPlayers = AllPlayers


   set Teams = GetPlayspace().GetTeamCollection().GetTeams()
   var MaybeTeam4 : ?team = option{GetPlayspace().GetTeamCollection().GetTeams()[3]}

    if (ValidTeam4 := MaybeTeam4?):
        for (Player : GetPlayspace().GetPlayers()):
             MaybeFortCharacter : ?fort_character = option{Player.GetFortCharacter[]}
             if (ValidFortCharacter := MaybeFortCharacter?):
                MaybeAgent : ?agent = option{ValidFortCharacter.GetAgent[]}
                  if (ValidAgent := MaybeAgent?):
                     if (GetPlayspace().GetTeamCollection().IsOnTeam[ValidAgent , ValidTeam4]): 
                                       # Player is on Team4
                     TeleportDropR2_1.Teleport(Player)
                        else:
                     TeleportDropR2_2.Teleport(Player)

Please don’t judge my excessive indentation :pray: :laughing:

EDIT : No event biding on theses devices.

1 Like

Salut man!

So, it seems that you’re really just teleporting the players, which is really strange. Can you check that those values are the same as mine :
image

Also be sure to check the Functions AND Events in UEFN :
image

In your Island Settings, this should be unchecked (not like mine) :
image

I guess you could double check all your devices that affect Player’s inventory, so Class Designers, Class Selectors, Team Inventory And Settings devices, Round Setting Devices.

Finally, I took time to reformat your code, since it could be really shorten as you also noticed, I find it a bit more readable, maybe you will prefer too :

TeamCollection := GetPlayspace().GetTeamCollection()
set Teams = TeamCollection.GetTeams()
if (ValidTeam4 := Teams[3]):
    for (
        Player : GetPlayspace().GetPlayers(),
        ValidFortCharacter := Player.GetFortCharacter[], # 'for' filter, appliqué à chaque iteration (comme un if)
        ValidAgent := ValidFortCharacter.GetAgent[], # 'for' filter
        TargetTeleporter := if(TeamCollection.IsOnTeam[ValidAgent , ValidTeam4]) then TeleportDropR2_1 else TeleportDropR2_2 # 'for' filter
    ):
        TargetTeleporter.Teleport(Player)

EDIT: This can work the same way instead I think :

if (ValidTeam4 := Teams[3]):
    for (
        Player : GetPlayspace().GetPlayers(),
        TargetTeleporter := if(TeamCollection.IsOnTeam[Player , ValidTeam4]) then TeleportDropR2_1 else TeleportDropR2_2 # Player is an Agent, and we assume he's valid, I don't think the Teleport function will crash if he isn't anyway
    ):
        TargetTeleporter.Teleport(Player)
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.