Skip to content
  • 0 Unread 0
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
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 262 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
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
    • Doobundefined Doob

      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 Offline
      JezuzLizardundefined Offline
      JezuzLizard
      Plutonium Staff
      wrote 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

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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