Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Running Script Once People Leave Spectator Mode

Running Script Once People Leave Spectator Mode

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
2 Posts 2 Posters 64 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Doobundefined Offline
    Doobundefined Offline
    Doob
    wrote on last edited by
    #1

    Are there any commands I could run to make scripts activate after someone exits spectator mode? Like when someone joins a server, and they get out of being a spectator, they don't receive perks that are supposed to be given or a weapon via a script.

    JezuzLizardundefined 1 Reply Last reply
    0
    • JezuzLizardundefined Offline
      JezuzLizardundefined Offline
      JezuzLizard Plutonium Staff
      replied to Doob on last edited by
      #2

      Doob You could do something fairly standard like this:

      on_player_connect() 
      {
          level endon( "end_game" ); //this kills the function when the game ends
          while ( true ) //this indicates we will keep doing this forever in this case it will call on_player_spawned(); for every player that connects to your server
          {
          	level waittill( "connected", player ); //this gets the player when they first connect
              //this function below calls a function with the particular connected player in mind
              player thread on_player_spawned(); //since this function we are calling is an infinite loop too it needs to be threaded
          }
      }
      
      on_player_spawned()
      {
              level endon( "end_game" );
              self endon( "disconnect" ); //we will kill the infinite loop if the player disconnects to tie up loose ends
      	while ( true )//this indicates it will do something for every time a player spawns in
      	{
      		self waittill( "spawned_player" ); //this is the event that occurs when the player first spawns in when a game starts and will also occur each time they spawn in from spectator
                      //call functions you want "self" which in this context is the player to do things with
                      //if you want to give perks every time a player spawns you would do it in this loop below the self waittill() line
              }
      }
      
      1 Reply Last reply
      0

      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Donate