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

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Having trouble making a script that gives the player Unlimited sprint on player spawn.

Having trouble making a script that gives the player Unlimited sprint on player spawn.

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
11 Posts 5 Posters 555 Views 3 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.
  • Unfunny_Umiundefined Offline
    Unfunny_Umiundefined Offline
    Unfunny_Umi
    wrote on last edited by
    #1

    This is my first time actively trying to write and use a script, so I'm brand new to this. Not exactly sure what it is I'm doing wrong. I've gotten the game to load and the bootstrapper is telling me that it's able to execute the script (it doesn't kick me out of the game or anything). But the player sprint is still default, in-game. They sprint for a few seconds and then stop, as usual.
    Anyone know how I can fix this?
    This is the script.
    Screenshot (214).png

    Eleven111undefined 1 Reply Last reply
    0
    • Xerxesundefined Online
      Xerxesundefined Online
      Xerxes
      Plutonium Staff
      wrote on last edited by
      #2

      You have to call your function on the player entity. Like welcome.

      Unfunny_Umiundefined 1 Reply Last reply
      1
      • Xerxesundefined Xerxes

        You have to call your function on the player entity. Like welcome.

        Unfunny_Umiundefined Offline
        Unfunny_Umiundefined Offline
        Unfunny_Umi
        wrote on last edited by
        #3

        Xerxes Thank you. Could you give me an example?

        Resxtundefined 1 Reply Last reply
        0
        • Unfunny_Umiundefined Unfunny_Umi

          Xerxes Thank you. Could you give me an example?

          Resxtundefined Offline
          Resxtundefined Offline
          Resxt
          Plutonium Staff
          wrote on last edited by Resxt
          #4

          Unfunny_Umi "like welcome" so just do the same
          In code there is always two steps:

          • Declaring a piece of code to make it available
          • Calling that piece of code (function) to actually use it

          Right now you're declaring the unlimited_sprint function, it exists, but it is never called/used on any entity.
          It just sits there but it's never used. Declaring a function doesn't do anything more than making it available.

          You added thread unlimited_sprint() but you don't thread on any object.
          You need to call the function on something (the level, a player etc.)

          So move this below player thread welcome() like Xerxes said.

          for (;;)
          {
              level waittill("connecting", player);
              player thread welcome();
              player thread unlimited_sprint();
          }
          

          This way you are saying "when a player connects thread the unlimited_sprint function on him on that particular player

          Unfunny_Umiundefined 1 Reply Last reply
          2
          • Resxtundefined Resxt

            Unfunny_Umi "like welcome" so just do the same
            In code there is always two steps:

            • Declaring a piece of code to make it available
            • Calling that piece of code (function) to actually use it

            Right now you're declaring the unlimited_sprint function, it exists, but it is never called/used on any entity.
            It just sits there but it's never used. Declaring a function doesn't do anything more than making it available.

            You added thread unlimited_sprint() but you don't thread on any object.
            You need to call the function on something (the level, a player etc.)

            So move this below player thread welcome() like Xerxes said.

            for (;;)
            {
                level waittill("connecting", player);
                player thread welcome();
                player thread unlimited_sprint();
            }
            

            This way you are saying "when a player connects thread the unlimited_sprint function on him on that particular player

            Unfunny_Umiundefined Offline
            Unfunny_Umiundefined Offline
            Unfunny_Umi
            wrote on last edited by
            #5

            Resxt You guys are the best. Genuinely, thank you so much.
            I got it working! Much Love!

            1 Reply Last reply
            1
            • Unfunny_Umiundefined Unfunny_Umi

              This is my first time actively trying to write and use a script, so I'm brand new to this. Not exactly sure what it is I'm doing wrong. I've gotten the game to load and the bootstrapper is telling me that it's able to execute the script (it doesn't kick me out of the game or anything). But the player sprint is still default, in-game. They sprint for a few seconds and then stop, as usual.
              Anyone know how I can fix this?
              This is the script.
              Screenshot (214).png

              Eleven111undefined Offline
              Eleven111undefined Offline
              Eleven111
              wrote on last edited by Eleven111
              #6

              Unfunny_Umi hey I've tried using your script but it did not work here is the script can you tell if it's correct I
              have no experience with coding

              init()
              {
              thread unlimited_sprint();
              for (;;)
              {
              level waittill("connecting", player);
              player thread welcome();
              player thread unlimited_sprint();
              }
              }

              unlimited_sprint()
              {
              self waittill("spawned_player");
              self setperk("specialty_unlimitedsprint");
              }
              welcome()

              {
              self endon("disconnect");
              self waittill("spawned_player");

              }

              Resxtundefined 1 Reply Last reply
              0
              • Eleven111undefined Eleven111

                Unfunny_Umi hey I've tried using your script but it did not work here is the script can you tell if it's correct I
                have no experience with coding

                init()
                {
                thread unlimited_sprint();
                for (;;)
                {
                level waittill("connecting", player);
                player thread welcome();
                player thread unlimited_sprint();
                }
                }

                unlimited_sprint()
                {
                self waittill("spawned_player");
                self setperk("specialty_unlimitedsprint");
                }
                welcome()

                {
                self endon("disconnect");
                self waittill("spawned_player");

                }

                Resxtundefined Offline
                Resxtundefined Offline
                Resxt
                Plutonium Staff
                wrote on last edited by
                #7

                Eleven111 the guy was asking for help coz his script didn't work so copy pasting it will obviously not work. Read the answers

                Eleven111undefined 1 Reply Last reply
                0
                • Resxtundefined Resxt

                  Eleven111 the guy was asking for help coz his script didn't work so copy pasting it will obviously not work. Read the answers

                  Eleven111undefined Offline
                  Eleven111undefined Offline
                  Eleven111
                  wrote on last edited by Eleven111
                  #8

                  Resxt I understand but you helped him with the code and he said it worked for him that's why I was asking him about it, because I tried using the code and I added that correct code that u mentioned and still did not work. any help would be appreciated

                  Resxtundefined 1 Reply Last reply
                  0
                  • Eleven111undefined Eleven111

                    Resxt I understand but you helped him with the code and he said it worked for him that's why I was asking him about it, because I tried using the code and I added that correct code that u mentioned and still did not work. any help would be appreciated

                    Resxtundefined Offline
                    Resxtundefined Offline
                    Resxt
                    Plutonium Staff
                    wrote on last edited by
                    #9

                    Eleven111 the code you've shown does not contain the modified code

                    1 Reply Last reply
                    0
                    • Eleven111undefined Offline
                      Eleven111undefined Offline
                      Eleven111
                      wrote on last edited by
                      #10

                      would you please help with the code. I'm illiterate when it comes to coding

                      Deicideundefined 1 Reply Last reply
                      0
                      • Eleven111undefined Eleven111

                        would you please help with the code. I'm illiterate when it comes to coding

                        Deicideundefined Offline
                        Deicideundefined Offline
                        Deicide
                        wrote on last edited by Deicide
                        #11

                        Eleven111 I myself was confused from the jump as to how OP got the beginning code he posted. Most .gsc contain three main functions and they call like such.

                        init()
                        {
                            level thread onPlayerConnect();
                        }
                        
                        onPlayerConnect()
                        {
                            for(;;)
                            {
                                level waittill("connected", player); //waits until you are connected to the server, before you spawn in.
                                player thread onPlayerSpawned();
                            }
                        }
                        
                        onPlayerSpawned()
                        {
                            self endon("disconnect");
                            level endon("game_ended");
                            for(;;)
                            {
                                self waittill("spawned_player"); //anything after this happens after you spawn in. You cannot set perks on a player that is not spawned in yet.
                            }
                        }
                        

                        Simply set the perk after said player spawns in. That's really where your problem lies. 😊

                        1 Reply Last reply
                        0
                        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
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Donate