Why doesn't it give the objects to the selected "Player"

Why doesn’t it give the objects to the selected “Player”…

I’ve been trying to make the code for a few days now to select the murderer, the sheriff and the innocents.

The murderer gets his gun, but the second player never gets anything.

What is the problem I have???

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/UI }
using { /Verse.org/Simulation }
using { /Verse.org/Random }
using { /Verse.org/Assets }
using { /Verse.org/Colors }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/UI }

SeleccionRol := class(creative_device):

    var PlayerMap : [player]SeleccionAsesino = map{}

    @editable var MinimoAleatorio : int = 0
    @editable var MaximoAleatorio : int = 0

    var NumeroAleatorioJugadores : []int = array{}

    var IndicadorJugadorMurder : int = -1
    var IndicadorJugadorSheriff : int = -1

    @editable  ItemGranterAsesino : item_granter_device = item_granter_device{}
    @editable  ItemGranterSheriff : item_granter_device = item_granter_device{}
    @editable  ItemGranterInocente : item_granter_device = item_granter_device{}

    @editable  TriggerActivador : trigger_device = trigger_device{}

    OnBegin< override>()<suspends>:void=
  
        TriggerActivador.TriggeredEvent.Subscribe(ObtenerJugadores)

    ObtenerJugadores(Agent : ?agent):void=
        GenerarNumeros(GetPlayspace().GetPlayers())
                    
    GenerarNumeros(Players : []player) : void =

        for(Jugadores : Players):
            set NumeroAleatorioJugadores += array:
                SelectorNumeroAleatorio : int = GetRandomInt(MinimoAleatorio, MaximoAleatorio)

        ElectorMurder(Players)        

    ElectorMurder(Jugadores : []player) : void =

        var TemporalAleatorio : int = 0
        
        Values := for (X : NumeroAleatorioJugadores): 
    
            if(X >= TemporalAleatorio):
                set IndicadorJugadorMurder += 1
                set TemporalAleatorio = X


        if(IndicadorJugadorMurder <> -1):

            if(Player := Jugadores[IndicadorJugadorMurder]):

                ItemGranterAsesino.GrantItem(Player) 
                ElectorSheriff()

    ElectorSheriff(Jugadores : []player) : void =


        for(Player : Jugadores):
            var TemporalParaBorrarAleatorios : int = 0
            if (NewArray := NumeroAleatorioJugadores.RemoveElement[TemporalParaBorrarAleatorios]):
                set NumeroAleatorioJugadores = NewArray
            set TemporalParaBorrarAleatorios += 1    
            


        for(Player : Jugadores):
            set NumeroAleatorioJugadores += array:
                SelectorNumeroAleatorio : int = GetRandomInt(MinimoAleatorio, MaximoAleatorio)

        var TemporalAleatorio : int = 0
        
        Values := for (Y : NumeroAleatorioJugadores): 
    
            if(Y >= TemporalAleatorio):
                set IndicadorJugadorSheriff += 1
                set TemporalAleatorio = Y


        if(IndicadorJugadorSheriff <> -1 and IndicadorJugadorSheriff <> IndicadorJugadorMurder):

            if(Player := Jugadores[IndicadorJugadorMurder]):

                ItemGranterSheriff.GrantItem(Player)                 
        else:
            ElectorSheriff()
                    
                



                
            
   
            


            


I don’t know verse, so I can’t point out the issue, but have you considered using player classes for the 3 different types.
The class designers can give the loadouts and different devices can use the class settings to affect them differently

1 Like

Thank you very much for your response, I really love people who try to help others! I have a great item just to test but just now I solved my problem after so long <3

It turns out that I had a wrong “Conditional” and I also didn’t pick up and reset the variable that determines who has the gun, so I exceeded the number of players in the tests and no one had a gun :slight_smile:

Thank you for your interest, if you need help, you can add to the discord, although I am Spanish but I am sure we understand each other <3
Discord: Fali_005

2 Likes

Thank you for responding with your fix, @Fali_005 :slight_smile:

1 Like