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

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. [Support] Code for distance meter for trickshots?

[Support] Code for distance meter for trickshots?

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
27 Posts 10 Posters 1.2k 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.
  • undefined Offline
    undefined Offline
    Lordship
    wrote on Mar 8, 2020, 12:09 PM last edited by Mr. Android Apr 2, 2020, 12:28 AM
    #1

    Does anybody know it? If so can they post below?

    1 Reply Last reply
    0
    • undefined Offline
      undefined Offline
      R1pzie
      wrote on Mar 8, 2020, 5:05 PM last edited by
      #2

      did you find the code yet?

      1 Reply Last reply
      0
      • undefined Offline
        undefined Offline
        Sass Plutonium Staff
        wrote on Mar 8, 2020, 8:43 PM last edited by Sass Mar 9, 2020, 1:12 PM
        #3

        Step 1 - Add the following in init() :

        level.onkillscore = level.onplayerkilled;
        level.onplayerkilled = ::onplayerkilled;
        

        Step 2 - Copy the following somewhere in your file :

        onPlayerKilled(einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration) 
        {
            thread [[level.onkillscore]](einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration);
            // ^ this is here so you can still score normally
            
            attacker iPrintLn("You killed " + self.name + " from " + int(distance(self.origin, attacker.origin)/40) + "m away");
        }
        
        1 Reply Last reply
        0
        • undefined Offline
          undefined Offline
          Cahz VIP
          wrote on Mar 8, 2020, 8:47 PM last edited by
          #4

          I'm not going to give an outright copy paste of the code, but I will give you the biggest piece that you need for it.

          meterdist = floor( Distance( self.origin, eattacker.origin ) / 46 );

          Note that I chose the number 46 to divide by because it seemed the most accurate with testing. It may not be 100% correct but it does the job. Good luck.

          undefined 1 Reply Last reply Mar 8, 2020, 8:49 PM
          0
          • undefined Offline
            undefined Offline
            Sass Plutonium Staff
            replied to Cahz on Mar 8, 2020, 8:49 PM last edited by Sass Mar 8, 2020, 10:57 PM
            #5

            I used 25 instead of 46. I tried 50, but 25 looked alot more accurate to me.

            Edit : nvm, I think somewhere around 40 is indeed better.

            1 Reply Last reply
            0
            • undefined Offline
              undefined Offline
              Ox_
              wrote on Mar 9, 2020, 1:28 AM last edited by
              #6

              One CoD world unit is 2.54cm.
              And for distance, an easy way is just in compare distance between the attacker and self (player who's about to get killed) in e.g the level.callbackplayerkilled function.

              undefined 1 Reply Last reply Mar 9, 2020, 4:00 AM
              0
              • undefined Offline
                undefined Offline
                Cahz VIP
                replied to Ox_ on Mar 9, 2020, 4:00 AM last edited by
                #7

                Ox_ Okay so if one CoD world unit is 2.54cm, then you would actually divide by 39.37.

                2.54 cm = 1 unit

                100 cm = 39.3700 units = 1 m

                undefined 1 Reply Last reply Mar 9, 2020, 5:27 AM
                0
                • undefined Offline
                  undefined Offline
                  Ox_
                  replied to Cahz on Mar 9, 2020, 5:27 AM last edited by
                  #8

                  Cahz said in Code for distance meter for trickshots?:

                  Ox_ Okay so if one CoD world unit is 2.54cm, then you would actually divide by 39.37.

                  2.54 cm = 1 unit

                  100 cm = 39.3700 units = 1 m

                  Well actually you'd divide by 5000/127, but maybe just multiply by 0.0254, be easier.

                  undefined 1 Reply Last reply Mar 9, 2020, 5:48 AM
                  0
                  • undefined Offline
                    undefined Offline
                    Cahz VIP
                    replied to Ox_ on Mar 9, 2020, 5:48 AM last edited by
                    #9

                    Ox_ said in Code for distance meter for trickshots?:

                    Cahz said in Code for distance meter for trickshots?:

                    Ox_ Okay so if one CoD world unit is 2.54cm, then you would actually divide by 39.37.

                    2.54 cm = 1 unit

                    100 cm = 39.3700 units = 1 m

                    Well actually you'd divide by 5000/127, but maybe just multiply by 0.0254, be easier.

                    5000/127 is literally 39.37... which works totally fine by the way. So no need to multiply

                    undefined 1 Reply Last reply Mar 9, 2020, 5:50 AM
                    0
                    • undefined Offline
                      undefined Offline
                      Ox_
                      replied to Cahz on Mar 9, 2020, 5:50 AM last edited by
                      #10

                      Cahz said in Code for distance meter for trickshots?:

                      Ox_ said in Code for distance meter for trickshots?:

                      Cahz said in Code for distance meter for trickshots?:

                      Ox_ Okay so if one CoD world unit is 2.54cm, then you would actually divide by 39.37.

                      2.54 cm = 1 unit

                      100 cm = 39.3700 units = 1 m

                      Well actually you'd divide by 5000/127, but maybe just multiply by 0.0254, be easier.

                      5000/127 is literally 39.37... which works totally fine by the way. So no need to multiply

                      It's not, but sure, it's close enough for most uses.

                      1 Reply Last reply
                      0
                      • undefined Offline
                        undefined Offline
                        Sass Plutonium Staff
                        wrote on Mar 9, 2020, 10:38 AM last edited by
                        #11

                        I already changed my post to 40 yesterday. That's more than good enough, it doesn't need to be dead-on precise.

                        1 Reply Last reply
                        1
                        • undefined Offline
                          undefined Offline
                          Sass Plutonium Staff
                          wrote on Mar 9, 2020, 10:44 AM last edited by Sass Mar 9, 2020, 1:20 PM
                          #12

                          I also feel so fucking dumb for not posting the right thing. I thought OP wanted a function that detects a player you almost hit and the distance between the impact and the player, not the distance from the player you just killed...


                          Edit )
                          Here's what you want to do. I also edited my first reply to include this script instead, sorry for the confusion. While I'm at it I included the "more precise" multiplier too since it seems to cause alot of debate for whatever reason.

                          Step 1 - Add the following in init() :

                          level.onkillscore = level.onplayerkilled;
                          level.onplayerkilled = ::onplayerkilled;
                          

                          Step 2 - Copy the following somewhere in your file :

                          onPlayerKilled(einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration) 
                          {
                              thread [[level.onkillscore]](einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration);
                              // ^ this is here so you can still score normally
                              
                              attacker iPrintLn("You killed " + self.name + " from " + int(distance(self.origin, attacker.origin)*0.0254) + "m away");
                          }
                          
                          Duui YTundefined 1 Reply Last reply May 25, 2020, 7:50 PM
                          1
                          • Duui YTundefined Offline
                            Duui YTundefined Offline
                            Duui YT
                            replied to Sass on May 25, 2020, 7:50 PM last edited by
                            #13

                            Sass how to make it so every one sees the message

                            Deicideundefined 1 Reply Last reply May 26, 2020, 4:56 PM
                            0
                            • Deicideundefined Offline
                              Deicideundefined Offline
                              Deicide
                              replied to Duui YT on May 26, 2020, 4:56 PM last edited by
                              #14

                              Duui YT said in [Support] Code for distance meter for trickshots?:

                              Sass how to make it so every one sees the message
                              Change this

                              attacker iPrintLn("You killed " + self.name + " from " + int(distance(self.origin, attacker.origin)*0.0254) + "m away");
                              
                              iPrintLn("You killed " + self.name + " from " + int(distance(self.origin, attacker.origin)*0.0254) + "m away");
                              

                              To this. You should try experimenting and figuring out some things yourself too 🙂

                              Duui YTundefined 1 Reply Last reply May 26, 2020, 11:08 PM
                              0
                              • Duui YTundefined Offline
                                Duui YTundefined Offline
                                Duui YT
                                replied to Deicide on May 26, 2020, 11:08 PM last edited by Duui YT May 27, 2020, 2:19 AM
                                #15

                                Deicide can i do this or it will not work

                                iPrintLn("+ self.name +  " + self.name + " from " + int(distance(self.origin, attacker.origin)*0.0254) + "m away");
                                
                                1 Reply Last reply
                                0
                                • Duui YTundefined Offline
                                  Duui YTundefined Offline
                                  Duui YT
                                  wrote on Jun 14, 2020, 7:37 PM last edited by Duui YT Jun 14, 2020, 10:42 PM
                                  #16

                                  it did not work it says it when someone dies not when they get a kill

                                  undefined 1 Reply Last reply Jun 14, 2020, 9:56 PM
                                  0
                                  • undefined Offline
                                    undefined Offline
                                    Sass Plutonium Staff
                                    replied to Duui YT on Jun 14, 2020, 9:56 PM last edited by
                                    #17

                                    It does work, I tested it just now. I'm not sure what the problem is.

                                    1 Reply Last reply
                                    1
                                    • Duui YTundefined Offline
                                      Duui YTundefined Offline
                                      Duui YT
                                      wrote on Jun 14, 2020, 10:59 PM last edited by Duui YT Jun 15, 2020, 1:59 AM
                                      #18

                                      Sass this is what i do as Deicide told me but it says it when someone dies not when they get a kill

                                      onPlayerKilled(einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration) 
                                      {
                                          thread [[level.onkillscore]](einflictor, attacker, idamage, smeansofdeath, sweapon, vdir, shitloc, psoffsettime, deathanimduration);
                                          // ^ this is here so you can still score normally
                                          
                                          iPrintLn(int(distance(self.origin, attacker.origin)*0.0254) + "m away");
                                      } 
                                      
                                      undefined undefined 2 Replies Last reply Jun 15, 2020, 1:40 AM
                                      0
                                      • undefined Offline
                                        undefined Offline
                                        Cahz VIP
                                        replied to Duui YT on Jun 15, 2020, 1:40 AM last edited by
                                        #19

                                        Duui YT
                                        When someone dies, does another player not get a kill?
                                        1 KILL (attacker) = 1 DEATH (self)

                                        You're literally making no sense when it comes to this. Instead of spamming the forums with questions over and over, how about do some research into the game files and ask YOURSELF, "why is this script behaving like this?" Instead of asking a million questions on the forums. (Which could all be solved on your own if you put a little time into learning)

                                        I personally don't like the idea of someone running a server that only knows how to copy and paste other people's scripts, but couldn't tell you how any of them work. This is exactly the type of stuff that leads to servers crashing more frequently due to poorly made/unstable scripts being used by someone who doesn't know that it is poorly made/unstable.

                                        Research GSC there's plenty of information out on the internet.

                                        1 Reply Last reply
                                        3
                                        • undefined Offline
                                          undefined Offline
                                          Sass Plutonium Staff
                                          replied to Duui YT on Jun 15, 2020, 1:57 AM last edited by Sass Jun 15, 2020, 5:03 AM
                                          #20

                                          Backing up on what Cahz , this is basic GSC knowledge. If you're willing to host servers with mods, you should atleast take the time to learn and comprehend how the script works. We could babysit you through the whole process, but that will never play in your favor and you'll be stuck because of the smallest issues such as this one. You can find plenty of resources and even tutorials with enough searching. Please take some time to learn, it will help you alot.

                                          1 Reply Last reply
                                          2

                                          • 1
                                          • 2
                                          • Login

                                          • Don't have an account? Register

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