Need help optimising scripts
-
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:- 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
- Make juggernog give you mule kick (specialty_additionalprimary weapon) only on maps that do not have mule kick (zm_prison, zm_transit, zm_nuked)
- 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.
-
@P00DL3W0Lf_GR For mule kick: (and any other buyable perk)
self thread givePerk("specialty_additionalprimaryweapon");
givePerk(perk) { self endon("disconnect"); self endon("death"); level endon("game_ended"); if (!self hasperk(perk) || self maps/mp/zombies/_zm_perks::has_perk_paused(perk)) { self thread maps/mp/zombies/_zm_perks::wait_give_perk(perk, 1); if (self maps/mp/zombies/_zm_laststand::player_is_in_laststand() || isDefined(self.intermission) && self.intermission) return; } }
You can use if(level.script == "zm_nuked") etc to check for maps. You can use mule kick on any map btw just some dont have a perk icon.
-
Oh, thanks a lot! I'll edit and test now.
-
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
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) -
@P00DL3W0Lf_GR oh my bad guess i gave misinformation. setperk should work for mule then idk
-
@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.
-
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)
-
@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. -
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...) -
This post is deleted!
-
This post is deleted!
-
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...)?
-
@P00DL3W0Lf_GR
level.get_player_weapon_limit = 3;
Add it in the init() function
-
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.
-
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.
-
@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; }
-
Kalitos This one works! Thank you for your time and effort! Cheers!