3. Subscribing to Player Events
3. Subscribing to Player Events
This step shows how to assign a weapon to a player at the start of the game.
This step shows how to assign a weapon to a player at the start of the game.
When a player spawns for the first time, grant them the first weapon in the WeaponGranters array. To do this, you’ll need to subscribe functions to each player spawn pad. See the Coding Device Interactions page for more details on subscribable events.
Follow these steps to subscribe to player spawn events and to assign their first weapon.
-
Add a new method
OnPlayerSpawn()to theteam_elimination_gameclass. This method makes sure that you assign the player the right weapon when they spawn for the first time, and when they respawn.| | OnPlayerSpawn(InPlayer : agent) : void = | | --- | --- | | | Print("A Player just spawned!") | Copy full snippet -
To subscribe the functions you just set up to their associated events, you need to add new code to
OnBegin(). Create aforloop to subscribe to each player spawner’sSpawnedEventusingOnPlayerSpawn.
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.