Creating Gun Game. Guns wont despawn after i die and just sit on the ground.

Creating Gun Game. Guns wont despawn after I die and just sit on the ground. I’m using verse code to run it. Does anybody have any ideas for how to delete them after i die so the arena isn’t littered with guns. Any ideas appreciated!

See code below if that helps. Its a combination of a YouTube tutorial and GPT4

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /Fortnite.com/Teams }
using { /Fortnite.com/Game }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/Diagnostics }

game_manager := class(creative_device):

var PlayerMap : [player]int = map{}

@editable
var WeaponGranters : []item_granter_device = array{}

@editable
var Sentries : []sentry_device = array{}

@editable
EndGameDevice : end_game_device = end_game_device{}

var ElimsToEndGame : int = 0

OnBegin<override>()<suspends>:void=
    set ElimsToEndGame = WeaponGranters.Length;
    InitPlayers()
    InitTestMode()

InitPlayers() : void=
    AllPlayers := GetPlayspace().GetPlayers()
    for (Player : AllPlayers, FortCharacter := Player.GetFortCharacter[]):
        if (set PlayerMap[Player] = 0, WeaponTier := PlayerMap[Player]):
            FortCharacter.EliminatedEvent().Subscribe(OnPlayerEliminated)
            GrantWeapon(Player, WeaponTier)

GrantWeapon(Player : player, WeaponTier: int) : void=
    Print("Attempting to grant weapon")
    if (ItemGranter := WeaponGranters[WeaponTier]):
        Print("Granted item to player")
        ItemGranter.GrantItem(Player)

OnPlayerEliminated(Result : elimination_result) : void=
    Eliminator := Result.EliminatingCharacter
    if (FortCharacter := Eliminator?, EliminatingAgent := FortCharacter.GetAgent[]):
        Print("We need to promote player")
        PromotePlayer(EliminatingAgent)

    # Grant weapon to the eliminated player
    if (EliminatedPlayer := player[Result.EliminatedCharacter.GetAgent[]], WeaponTier := PlayerMap[EliminatedPlayer]):
        GrantWeapon(EliminatedPlayer, WeaponTier)

PromotePlayer(Agent : agent) : void=
    var WeaponTier : int = 0
    if (Player := player[Agent], PlayerWeaponTier := PlayerMap[Player]):
        set WeaponTier = PlayerWeaponTier + 1
        CheckEndGame(Agent, WeaponTier)
                
    if (Player := player[Agent], set PlayerMap[Player] = WeaponTier):
        GrantWeapon(Player, WeaponTier)

InitTestMode() : void=
    for (Sentry : Sentries):
        Sentry.EliminatedEvent.Subscribe(TestPlayerElimination)

TestPlayerElimination(Agent : ?agent) : void=
    Print("Sentry eliminated!")
    if (Player := Agent?):
        PromotePlayer(Player)
   
CheckEndGame(Player : agent, WeaponTier : int) : void=
    if (WeaponTier >= ElimsToEndGame):
        EndGameDevice.Activate(Player)

I don’t believe this is manageable with code, but you can do this in two different places in UEFN:

  1. The island settings: Change the setting for “Eliminated Player’s items” to “delete”.

  2. Put in a class designer, change the same setting in there as the island one and then assign the default class in the island settings to that class.

3 Likes

In your Island settings their is an option to disable item dropping. Also when you are granting the Player the current tier weapon on death, if its set to clear items it should remove the weapons from them as soon as they die so there not kept.

2 Likes

Their is no GetGunObject() in fort_character? And if their was it would need to have the decides modifier to be used inside a conditional statement like that and would be GetGunObject[].

I don’t mean to be rude, but did you copy and paste that from ChatGPT?

It’s spam, you can tell with the link down at the bottom of the “answer” given.

Not going to lie was pretty funny to read especially this part:

Here’s an example of how you can modify your code:

python
Copy code

It’s a chat gpt response
But yea it’s pretty funny lol

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