My Give All Perks Script Isn't Working

Topic created ยท 9 Posts ยท 158 Views
  • So I made a simple script that should give all players all perks on the map. The issues I am having are, you get juggernog but, you don't get the health boost. The script also doesn't run again once the game resets, only once. My code for the script is below, please help in anyway possible.

    init()
    {
    
        for(;;)
        {
            level waittill("connected", player);
    		player thread onPlayerConnect();
    }
    }
    
    PerkTest()
    {
    	self give_perk("specialty_armorvest");
    	self give_perk("specialty_quickrevive");
    	self give_perk("specialty_fastreload");
    	self give_perk("specialty_rof");
    	self give_perk("specialty_longersprint");
    }
    
    onPlayerConnect()
    {
    	self thread PerkTest();
    }
    
  • @Doob its simple you give perk when player connect. Thats mean he can't get it because he is not in the game he is just connecting to the server. You have to give him perks when player spawn

  • How would I give players the perk once they spawn in? What function would I use?

  • @Doob

    perkTest(){
        for(;;){
    	self waittill("spawned_player");
            self give_perk("specialty_armorvest");
    	self give_perk("specialty_quickrevive");
    	self give_perk("specialty_fastreload");
    	self give_perk("specialty_rof");
    	self give_perk("specialty_longersprint");
        }
    }
    
  • Thanks for the fix it worked ๐Ÿ™‚
    Now my perk icons won't show once I've given the perks. Is there anyway to fix that?

  • @Doob
    With give_perk("specialty_armorvest"); will give just the perk ability. You can use this function to give the perk ability and show the icon. This funcion will show also the drink animations when you give the perk.

    doGivePerk(perk)
    {
        self endon("disconnect");
        self endon("death");
        level endon("game_ended");
        self endon("perk_abort_drinking");
        if (!(self hasperk(perk) || (self maps/mp/zombies/_zm_perks::has_perk_paused(perk))))
        {
            gun = self maps/mp/zombies/_zm_perks::perk_give_bottle_begin(perk);
            evt = self waittill_any_return("fake_death", "death", "player_downed", "weapon_change_complete");
            if (evt == "weapon_change_complete")
                self thread maps/mp/zombies/_zm_perks::wait_give_perk(perk, 1);
            self maps/mp/zombies/_zm_perks::perk_give_bottle_end(gun, perk);
            if (self maps/mp/zombies/_zm_laststand::player_is_in_laststand() || isDefined(self.intermission) && self.intermission)
                return;
            self notify("burp");
        }
    }
    
  • @Doob I figured I'd make a simple script that would work for all maps giving all perks.
    It uses some of Treyarch's code from buried to work but slightly modified:

    #include maps/mp/zombies/_zm_utility;
    #include maps/mp/_utility;
    #include common_scripts/utility;
    #include maps/mp/zombies/_zm_perks;
    
    init()
    {
        level thread on_player_connect();
    }
    
    on_player_connect()
    {
        level endon( "end_game" );
        while ( true )
        {
            level waittill( "connected", player );
            player thread on_player_spawned();
            player thread sq_give_player_all_perks();
        }
    }
    
    on_player_spawned()
    {
        level endon( "end_game" );
        self endon( "disconnect" );
        while ( true )
        {
            self waittill( "spawned_player" );
        }
    }
    
    sq_give_player_all_perks()
    {
        flag_wait( "initial_blackscreen_passed" );
        if ( level.script != "zm_tomb" )
        {
            machines = getentarray( "zombie_vending", "targetname" );
            perks = [];
            i = 0;
            while ( i < machines.size )
            {
                if ( machines[ i ].script_noteworthy == "specialty_weapupgrade" )
                {
                    i++;
                    continue;
                }
                perks[ perks.size ] = machines[ i ].script_noteworthy;
                i++;
            }
        }
        else 
        {
            perks = level._random_perk_machine_perk_list;
        }
    	foreach ( perk in perks )
    	{
    		if ( isDefined( self.perk_purchased ) && self.perk_purchased == perk )
    		{
    		}
    		else
    		{
    			if ( self hasperk( perk ) || self maps/mp/zombies/_zm_perks::has_perk_paused( perk ) )
    			{
    			}
    			else
    			{
    				self maps/mp/zombies/_zm_perks::give_perk( perk, 0 );
    				wait 0.25;
    			}
    		}
    	}
        if ( getDvarInt( "players_keep_perks_permanently" ) == 1 )
        {
            if ( !is_true( self._retain_perks ) )
            {
                self thread watch_for_respawn();
                self._retain_perks = 1;
            }
        }
    }
    
    watch_for_respawn()
    {
        level endon( "end_game" );
        self endon( "disconnect" );
        while ( true )
        {
            self waittill_either( "spawned_player", "player_revived" );
            wait_network_frame();
            self thread sq_give_player_all_perks();
            self setmaxhealth( level.zombie_vars[ "zombie_perk_juggernaut_health" ] );
        }
    }
    

    You can set this dvar: players_keep_perks_permanently to 1 in your server config for players to never lose perks even if they down, or bleedout. If you play solo with this mod with the dvar set you'll also have infinite quick revives.

  • @JezuzLizard Wow, big thanks dude! Fantastic script : )
    I do have two questions though, by server config for the perma perk value do you mean like in the dedicated_zm.cfg? Also are there any work arounds for mob of the dead? You do get the perks at the start but since you down at the beginning you loose them.

  • @Doob Its difficult to make it work on mob since mob has its own system with how perks work when you down. What you could do is make the script give the perks every time a player respawns or is revived.

Log in to reply