Modme Forums
Menu:

Help make this script have multiple shootable doors

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: KillJoyYT
function main

level shootable_trigs();








bottom of gsc


function shootable_trigs()
{
level.shootable_door_count = 0;
trigs = GetEntArray( "shootable_door", "targetname" );
level.shootable_door_goal = trigs.size;
foreach( trig in trigs )
trig thread wait_for_shoot();
}

function wait_for_shoot()
{
self waittill( "trigger", player );
player PlayLocalSound( "zmb_cha_ching" ); // Change this to any sound alias you want
level.shootable_door_count++;
if( level.shootable_door_count == level.shootable_door_goal )
self open_door();
}

function open_door()
{
doors = GetEntArray( "shootable_door_reward", "targetname" );

foreach( door in doors )
door PlaySound( "zmb_cha_ching" );
wait(0.05);
foreach( door in doors )
door delete();

flag = doors[0].script_flag;
level flag::set( flag );
}


ModmeBot:

Reply By: modric
Isn't it already able to use multiple trigs and doors? It uses GetEntArray, not just GetEnt. You can use as many trigs and doors as you want. Unless you mean another group of trigs opens a different door, then all you have to do is copy this whole thing and rename the functions and entities, also make sure to change the threads.


ModmeBot:

Reply By: modric

level shootable_trigs2();
 
 
 
 
 
 
 
 
bottom of gsc
 

function shootable_trigs2()
{
    level.shootable_door_count2 = 0; 
    trigs = GetEntArray( "shootable_door2", "targetname" ); 
    level.shootable_door_goal2 = trigs.size; 
    foreach( trig in trigs )
        trig thread wait_for_shoot2(); 
}
 
function wait_for_shoot2()
{
    self waittill( "trigger", player ); 
    player PlayLocalSound( "zmb_cha_ching" );   // Change this to any sound alias you want
    level.shootable_door_count2++; 
    if( level.shootable_door_count2 == level.shootable_door_goal2 )
        self open_door2(); 
}
 
function open_door2()
{
    doors = GetEntArray( "shootable_door_reward2", "targetname" ); 
    
    foreach( door in doors )
        door PlaySound( "zmb_cha_ching" ); 
    wait(0.05); 
    foreach( door in doors )
        door delete(); 
    
    flag = doors[0].script_flag; 
    level flag::set( flag ); 
}


ModmeBot:

Reply By: KillJoyYT
ive tried multiple different methods including the one you have mentioned but I will give it another go thank you

IT WORKED =)