How to use item granter on everyone?

Hello!! I’m trying to grant one gold to everyone playing once a minute in the device settings I already have it set to grant to everyone when activated but in Verse it requires an agent but I’m not sure what to put to resolve it thanks! :smiley:

@editable
    GoldGranter : item_granter_device = item_granter_device{}

GamePlayGold()<suspends> : void =
        loop:
            Sleep(60.0)
            TimePlayedGold.GrantItem() # Needs agent?

OnBegin<override>()<suspends>:void=
GamePlayGold()

I did a tutorial on the item granter a while back, here is the part where the coding gets going: UEFN Tutorial: Beginning Verse Programming To Grant Items - YouTube

2 Likes

This should work:

for(Player : GetPlayspace().GetPlayers()):
    TimePlayedGold.GrantItem(Player)

This will grant items to all players (alive or not, in spectator or not, I think)
You could filter the spectator ones with this function:

(InPlayer:player).IsSpectator<native><public>()<transacts><decides>:void

Also, I’m pretty this works on dead people (Assuming they keep their items on dying)

Item Granters that are set to grant to “All” automatically grant to everyone including spectators. In order to NOT do this, you’d have to use other methods of filtering it either through Verse or Devices like a player counter device or a mutator zone device.

1 Like

I have question. Is there an easy way to cycle through each player and grant the item individually? This is in the case of granting randomly a set of items.


This is what I have and it cycles a random amount out of presets. But it gives that random amount to ALL players and they all have the same amount. I know I can grab the player index and go through all the players one by one and grant each time. but the code would get extremely long. Is there an easier way were I can get it to do this automatically without me typing each player in the index out?