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

Plutonium

  1. Home
  2. BO2 Modding Support & Discussion
  3. Need help optimising scripts

Need help optimising scripts

Scheduled Pinned Locked Moved BO2 Modding Support & Discussion
17 Posts 4 Posters 420 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.
  • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

    chasef7 Hey it's me again. There is a problem with the givePerk thread. It crashes the game when it activates on maps that do not have mulekick by default and gives me the following error codeΣτιγμιότυπο οθόνης (25).png
    This is the same error code thatI was getting in the afterlife crash that I mentioned in the original post (but that was only on MoB)

    chasef7undefined Offline
    chasef7undefined Offline
    chasef7
    Banned
    wrote on last edited by chasef7
    #5

    @P00DL3W0Lf_GR oh my bad guess i gave misinformation. setperk should work for mule then idk

    1 Reply Last reply
    0
    • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

      chasef7 Hey it's me again. There is a problem with the givePerk thread. It crashes the game when it activates on maps that do not have mulekick by default and gives me the following error codeΣτιγμιότυπο οθόνης (25).png
      This is the same error code thatI was getting in the afterlife crash that I mentioned in the original post (but that was only on MoB)

      JezuzLizardundefined Offline
      JezuzLizardundefined Offline
      JezuzLizard
      Plutonium Staff
      wrote on last edited by
      #6

      @P00DL3W0Lf_GR It crashes because the mule kick perk bottle isn't on the map and it tries to give an invalid weapon. You'll have to write your own custom logic or not play the perk bottle drink animation.

      Z3NlTH-Dr4G0Nundefined 2 Replies Last reply
      0
      • JezuzLizardundefined JezuzLizard

        @P00DL3W0Lf_GR It crashes because the mule kick perk bottle isn't on the map and it tries to give an invalid weapon. You'll have to write your own custom logic or not play the perk bottle drink animation.

        Z3NlTH-Dr4G0Nundefined Offline
        Z3NlTH-Dr4G0Nundefined Offline
        Z3NlTH-Dr4G0N
        wrote on last edited by
        #7

        JezuzLizard Interesting. Well I have no idea how to disable the perk drink animation since I am very inexperienced with scripting. Also, does that explain the crash on MoB when I revive myself while having jugg (I was using self setperkand it only crashed on MoB)

        1 Reply Last reply
        0
        • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

          Hello everyone! I need a little bit of help optimising some scripts that I have

          init()
          {
           	level thread onplayerconnect();
          }
          
          onplayerconnect()
          {
          	for ( ;; )
          	{
          		level waittill( "connecting", player );
          		player thread onplayerspawned();
          	}
          }
          
          onplayerspawned()
          {
          	level endon( "game_ended" );
              self endon( "disconnect" );
          
              	self.initial_spawn = true;
          
              for(;;)
              {
                  self waittill( "spawned_player" );
                  self IPrintLnBold( "Max Health Boosted From 100hp to 150hp" );
          		self.maxhealth=150;
                  self.health=self.maxhealth;
          		self thread onplayerrevived();
              }
          }
          
          onplayerrevived()
          {
          	level endon( "game_ended" );
          	self endon( "disconnect" );
          	
          	for(;;)
              {
          	    self waittill( "player_revived" );
                  max_total_health = 150;
                  self setmaxhealth( max_total_health );
          		self unsetperk("specialty_movefaster");
          	    self unsetperk("specialty_fallheight");
          		self unsetperk("specialty_stalker");
          		self unsetperk("specialty_unlimitedsprint");
          		self unsetperk("specialty_fastweaponswitch");
          		self unsetperk("specialty_additionalprimaryweapon");
          	    self thread checkjugg();
          		self thread checkstam();
          		self thread checkspeed();
              }
          }
          
          checkjugg()
          {
          wait 0.5;
              if( self hasperk( "specialty_armorvest" ))
          	{
          	    max_total_health = 350;
                  self setmaxhealth( max_total_health );
          		self setperk("specialty_additionalprimaryweapon");
          	}
          }
          
          checkstam()
          {
          wait 0.5;
              if( self hasperk( "specialty_longersprint" ))
          	{
          	    self setperk("specialty_movefaster");
          		self setperk("specialty_fallheight");
          		self setperk("specialty_stalker");
          		self setperk("specialty_unlimitedsprint");
          	}
          }
          
          checkspeed()
          {
          wait 0.5;
              if( self hasperk( "specialty_fastreload" ))
          	{
          	  self setperk("specialty_fastweaponswitch");  
          	}
          }
          

          This one is for increasing my health to 150 and keeping it like that when I get revived. (original creator Fennecsou)

          init()
          {
          	level thread onPlayerConnect();
          }
          
          onPlayerConnect()
          {
          	for(;;)
          	{
          		level waittill("connected", player);
          
          		player thread onPlayerSpawned();
          	}
          }
          
          onPlayerSpawned()
          {
          	level endon("end_game");
          	self endon("disconnect");
          	for(;;)
          	{
          		self waittill("spawned_player");
          		self thread staminup();
          		self thread speedcola();
          		self thread juggernog();
          	}
          }
          
          staminup()
          {
          	level endon("end_game");
          	self endon("disconnect");
          	for (;;)
          	{
          		self waittill("perk_acquired", "perk_lost");
          	
          		if (self hasperk("specialty_longersprint"))
          		{
          			self setperk("specialty_movefaster");
          			self setperk("specialty_fallheight");
          			self setperk("specialty_stalker");
          			self setperk("specialty_unlimitedsprint");
          		}
          		else
          		{
          			self unsetperk("specialty_movefaster");
          			self unsetperk("specialty_fallheight");
          			self unsetperk("specialty_stalker");
          			self unsetperk("specialty_unlimitedsprint");
          		}
          	}
          }
          
          speedcola()
          {
          	level endon("end_game");
          	self endon("disconnect");
          	for (;;)
          	{
          		self waittill("perk_acquired", "perk_lost");
          	
          		if (self hasperk("specialty_fastreload"))
          		{
          			self setperk("specialty_fastweaponswitch");
          		}
          		else
          		{
          			self unsetperk("specialty_fastweaponswitch");
          		}
          	}
          }
          
          juggernog()
          {
              level endon("end_game");
          	self endon("disconnect");
          	for (;;)
          	{
          		self waittill("perk_acquired", "perk_lost");
                  
          		if( self hasperk( "specialty_armorvest" ))
          	    {
          	        max_total_health = 350;
                      self setmaxhealth( max_total_health );
          			self setperk("specialty_additionalprimaryweapon");
          	    }
          		else
          		{
          		    max_total_health = 150;
          		    self setmaxhealth( max_total_health );
          		}
              }
          }
          

          And this is for some tweaks to perks.
          As you can see in the first script it includes retaining/ removing extra buff (stalker, nofalldamage etc.) because I couldn't get it to work in the second scrpt due to my very limited experience. I tried "waittill_any" but it gives me unresolved external error in game.
          So I want some help with:

          1. Putting all of the code for removing (when I lose the corresponding perks)/retaining (when I get revived but keep the perks like in die rise with who's who) the upgrades in the second script, when I
          2. Make juggernog give you mule kick (specialty_additionalprimary weapon) only on maps that do not have mule kick (zm_prison, zm_transit, zm_nuked)
          3. Fixing a crash that occurs in Mob Of The Dead everytime I revive yself in afterlife while having juggernog after I use the afterlife box to open up the map.
          Kalitosundefined Offline
          Kalitosundefined Offline
          Kalitos
          wrote on last edited by
          #8

          @P00DL3W0Lf_GR https://forum.plutonium.pw/topic/26201/zm-town-custom-perks
          You can guide the code of this script to get customized mule kick as you need. in addition to obtaining many more perks.

          1 Reply Last reply
          0
          • JezuzLizardundefined JezuzLizard

            @P00DL3W0Lf_GR It crashes because the mule kick perk bottle isn't on the map and it tries to give an invalid weapon. You'll have to write your own custom logic or not play the perk bottle drink animation.

            Z3NlTH-Dr4G0Nundefined Offline
            Z3NlTH-Dr4G0Nundefined Offline
            Z3NlTH-Dr4G0N
            wrote on last edited by Z3NlTH-Dr4G0N
            #9

            JezuzLizard Ok so I can get mule kick to work on green run and nuketown but I cannot get itto work on mob. Well it does activate when I buy jugg as it should but if I enter afterlife (through the afterlife boxes and not by getting downed) and revive myself the game crashes the moment the revive bar fills and gives the same error code that I posted above. My assumption is that it tries to load the perk icon but fails because it only exists on grief and not MoTD.
            If I remove mule kick from the script MoB works fine (but then I do't have mule kick...)

            chasef7undefined 1 Reply Last reply
            0
            • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

              JezuzLizard Ok so I can get mule kick to work on green run and nuketown but I cannot get itto work on mob. Well it does activate when I buy jugg as it should but if I enter afterlife (through the afterlife boxes and not by getting downed) and revive myself the game crashes the moment the revive bar fills and gives the same error code that I posted above. My assumption is that it tries to load the perk icon but fails because it only exists on grief and not MoTD.
              If I remove mule kick from the script MoB works fine (but then I do't have mule kick...)

              chasef7undefined Offline
              chasef7undefined Offline
              chasef7
              Banned
              wrote on last edited by
              #10
              This post is deleted!
              1 Reply Last reply
              0
              • chasef7undefined Offline
                chasef7undefined Offline
                chasef7
                Banned
                wrote on last edited by
                #11
                This post is deleted!
                1 Reply Last reply
                0
                • Z3NlTH-Dr4G0Nundefined Offline
                  Z3NlTH-Dr4G0Nundefined Offline
                  Z3NlTH-Dr4G0N
                  wrote on last edited by
                  #12

                  New idea: is there a way to increase the weapon limit to 3 from 2 without using "specialty_additionalprimaryweapon" and if yes, what is the name (maxweapons, setweaponlimit etc...)?

                  Kalitosundefined 2 Replies Last reply
                  0
                  • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

                    New idea: is there a way to increase the weapon limit to 3 from 2 without using "specialty_additionalprimaryweapon" and if yes, what is the name (maxweapons, setweaponlimit etc...)?

                    Kalitosundefined Offline
                    Kalitosundefined Offline
                    Kalitos
                    wrote on last edited by Kalitos
                    #13

                    @P00DL3W0Lf_GR

                    level.get_player_weapon_limit = 3;
                    

                    Add it in the init() function

                    Z3NlTH-Dr4G0Nundefined JezuzLizardundefined 2 Replies Last reply
                    0
                    • Kalitosundefined Kalitos

                      @P00DL3W0Lf_GR

                      level.get_player_weapon_limit = 3;
                      

                      Add it in the init() function

                      Z3NlTH-Dr4G0Nundefined Offline
                      Z3NlTH-Dr4G0Nundefined Offline
                      Z3NlTH-Dr4G0N
                      wrote on last edited by
                      #14

                      Kalitos Unfortunately that doesn't work. The sound that the box plays when it moves is constantly playing and the game keeps giving and taking away my 1911 while also taking points from me. No idea... STUPID MAP.

                      1 Reply Last reply
                      0
                      • Kalitosundefined Kalitos

                        @P00DL3W0Lf_GR

                        level.get_player_weapon_limit = 3;
                        

                        Add it in the init() function

                        JezuzLizardundefined Offline
                        JezuzLizardundefined Offline
                        JezuzLizard
                        Plutonium Staff
                        wrote on last edited by
                        #15

                        Kalitos @P00DL3W0Lf_GR That variable is used as a function ptr not a number. You need to create a function that returns a value for it to work properly.

                        1 Reply Last reply
                        1
                        • Z3NlTH-Dr4G0Nundefined Z3NlTH-Dr4G0N

                          New idea: is there a way to increase the weapon limit to 3 from 2 without using "specialty_additionalprimaryweapon" and if yes, what is the name (maxweapons, setweaponlimit etc...)?

                          Kalitosundefined Offline
                          Kalitosundefined Offline
                          Kalitos
                          wrote on last edited by
                          #16

                          @P00DL3W0Lf_GR

                          init()
                          {
                          level.get_player_weapon_limit = ::custom_get_player_weapon_limit;
                          }
                          
                          
                          custom_get_player_weapon_limit( player )
                          {
                              weapon_limit = 3;
                          
                              return weapon_limit;
                          }
                          
                          Z3NlTH-Dr4G0Nundefined 1 Reply Last reply
                          1
                          • Kalitosundefined Kalitos

                            @P00DL3W0Lf_GR

                            init()
                            {
                            level.get_player_weapon_limit = ::custom_get_player_weapon_limit;
                            }
                            
                            
                            custom_get_player_weapon_limit( player )
                            {
                                weapon_limit = 3;
                            
                                return weapon_limit;
                            }
                            
                            Z3NlTH-Dr4G0Nundefined Offline
                            Z3NlTH-Dr4G0Nundefined Offline
                            Z3NlTH-Dr4G0N
                            wrote on last edited by
                            #17

                            Kalitos This one works! Thank you for your time and effort! Cheers!

                            1 Reply Last reply
                            1
                            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