Reply to thread

Hello,

I got the door count to increment per person when someone opens a door but how would I get the cumulative cost of doors/debris per person opened.


UPDATE: I got it to work using array::thread_all, I found this works for all trigger objects with a function handler. Some code was pulled from scripts\zm\_zm_blockers.gsc


[CODE=clike]function init(){

    zombie_doors = GetEntArray( "zombie_door", "targetname" );

     if (isdefined(zombie_doors)){

             array::thread_all(zombie_doors,&monitorDoors);

      }

     zombie_debris = GetEntArray( "zombie_debris", "targetname" );

     if (isdefined(zombie_debris)){

             array::thread_all(zombie_debris,&monitorDebris);

      }

}


function monitorDoors(){

    self endon("disconnect");

    self endon("destroyMenu");

    level endon("game_ended");

    self waittill( "trigger", who, force );

    if ( isdefined( level.custom_door_buy_check ) )

    {

        if ( !who [[ level.custom_door_buy_check ]]( self ) )

        {

            return false;

        }

    }

    if(GetDvarInt( "zombie_unlock_all") > 0 || IS_TRUE( force ) )

    {

        return true;

    }


    if( !who UseButtonPressed() )

    {

        return false;

    }


    if( who zm_utility::in_revive_trigger() )

    {

        return false;

    }


    if( IS_DRINKING(who.is_drinking) )

    {

        return false;

    }

    cost = 0;

    upgraded = 0;

    if( zm_utility::is_player_valid( who ) )

    {

        players = GetPlayers();

        cost = self.zombie_cost;

        if (self._door_open == true){

            return false;

        }

        else if (who zm_score::can_player_purchase( cost )){

            who incSpent(cost);

        }

        else{

            return false;

        }

    }

}


function monitorDebris(){

    self endon("disconnect");

    self endon("destroyMenu");

    level endon("game_ended");

    while( 1 ){

        self waittill( "trigger", who, force );


        if(GetDvarInt( "zombie_unlock_all") > 0 || IS_TRUE( force ) )

        {

            //bypass.

        }

        else

        {

            if( !who UseButtonPressed() )

            {

                continue;

            }


            if( IS_DRINKING(who.is_drinking) )

            {

                continue;

            }


            if( who zm_utility::in_revive_trigger() )

            {

                continue;

            }

        }


        if( zm_utility::is_player_valid( who ) )

        {

            // Can we afford this door?

            players = GetPlayers();

            if(GetDvarInt( "zombie_unlock_all") > 0)

            {

                // bypass charge.

            }

            else if ( /*players.size == 1 &&*/ who zm_score::can_player_purchase( self.zombie_cost ) )

            {

                who incSpent(self.zombie_cost);

                return true;

            }

            else

            {

                continue;

            }

    }

}

}

[/CODE]


Top