What is in the tuple payload for VehicleSpawnedEvent?

when subscribing to the VehicleSpawnedEvent, what data should I expect to receive in my handler event in the “tuple()”

Also, I’ve looked for documentation regarding this and could not find much.
Thanks in advance!

OnBegin<override>()<suspends>:void=
    ATK_Vehicle.VehicleSpawnedEvent.Subscribe(OnATKSpawned)

OnATKSpawned(Payload: tuple()):void=
    Print("test")
2 Likes

You should be able to use a function that doesn’t take any parameters (empty tuple).

Thanks, also, what would I need to do if I want a reference to the spawned vehicle in the handler function?

1 Like

^ seconded, looking to spawn vehicles dynamically and can’t figure out how to move them. are spawned vehicles props and able to use MoveTo?
or, if using a vehicle reference isn’t an option, is there a function to move the spawner device itself?

1 Like

AFAIK there’s no way to get the reference to the vehicle except once the player is already in it, using MyFortCharacter.GetVehicle[]. However you can also move the spawner itself by making it a child of a prop and then moving the prop.

3 Likes

Thank you, this is useful. I can use both of these ideas.

How do I instantiate a class level property for the fort_vehicle that is returned from GetVehicle[]. I need to keep track of which vehicle the player exited.

I’m getting errors for the following 2 ways:

PlayerVehicle : fort_vehicle = fort_vehicle[]
This type invocation has the ‘decides’ effect, which is not allowed by its context.(3512)
Dynamic cast tuple() to fort_vehicle: argument type tuple() must be a class.

PlayerVehicle : fort_vehicle = fort_vehicle{}
fort_vehicle is not a macro.

You need to wrap it up in an optional like this :

PlayerVehicle : ?fort_vehicle = false

The second way would actually be the one to use :

PlayerVehicle : fort_vehicle = fort_vehicle{} # not allowed

If there was any constructor for this device, some devices have constructors exposed some don’t (for example you could have done) :

HUDMessageDevice : hud_message_device = hud_message_device{} # this constructor is exposed

Also if your class wasn’t <concrete> (like every creative_device), you could have simply done this :

PlayerVehicle : fort_vehicle
1 Like

I’ve modified my code per your suggestion, thank you.
this line of code is not successful:

PlayerVehicle = FortCharacter.GetVehicle[]

Full code:

    PlayerVehicle : ?fort_vehicle = false

    OnBegin<override>()<suspends>:void=
        # vehicle spawner
        ATK_Vehicle.AgentEntersVehicleEvent.Subscribe(OnAgentEntersVehicle)

    OnAgentEntersVehicle(Agent : agent):void=
        if:
            FortCharacter := Agent.GetFortCharacter[]
        then:
            Print("got FortCharacter")
            if: 
                PlayerVehicle = FortCharacter.GetVehicle[]
            then:
                Print("got PlayerVehicle")

For those looking to move devices and vehicles, I figured it out by following this tutorial:

@M3NTA7-OG, I’d recommend a map to keep track of players and the vehicles they enter/exit. Something like:

var VehicleMap : [player]fort_vehicle = map{}

You need to store it as an optional like this :

if (_PlayerVehicle = FortCharacter.GetVehicle[]):
    set PlayerVehicle = option{_PlayerVehicle}
    Print("got PlayerVehicle")

Also your PlayerVehicle is a constant and should be a variable in order to be editable :

var PlayerVehicle : ?fort_vehicle = false

But DJEJ22 is right, if your island is not supposed to be played alone only, you need to store the data for every players in your island, hence using the map container.

1 Like