item_granter_device GrantItemIndex doesn't always grent item

In our game, we give player a weapon when the game start/when they join the game using Item Granter. We notice an issue specifically on player join a running session, they might not have their weapon. (nvm, it is extremely rare, but I found a case on launching player)

At first, we thought it might be the player is not in a good state, so I did a check to make sure the player has agent and fort_character all accessible before we give them weapon. It doesn’t seem to take care of most of the cases. However, we are still seeing player not having a weapon in some occasion. In the test, we can verify that it did called GrantItemIndex, but the player does not have the weapon.

I am wondering if this is a bug in item_granter_device? Any help will be appreciated!

SetFirstItem(Player:player)<suspends>:void=
        var successed : logic := false
        loop:
            if(FortChar := Player.GetFortCharacter[], ThisAgent := FortChar.GetAgent[]):
                ItemGranters.GrantItemIndex(ThisAgent,0)
                Print("someone got there first weapon")
                set successed = true
            if(successed = true):
                break
            Print("someone joined but not ready for first weapon")
            Sleep(0.1)

Do you also check if the fort_character is active ?

I believe there’s also a checkbox on the item granter that says grant while offline maybe you can try that, otherwise you need to add a delay before granting the weapons on JIP

If it’s an issue you have, you’ll probably manage to repro it with a Nintendo Switch

It seems like it does help, thank you!

1 Like