UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: daedra descent on May 26, 2014, 05:04:36 am

Title: zone spawner getting script
Post by: daedra descent on May 26, 2014, 05:04:36 am
Just want to check to see if anyone could find a problem with this script. "Self" is a zone.

Code Snippet
Plaintext
get_zone_spawners()
{
spawners = undefined;

zones = getentarray(self.script_noteworthy,"script_noteworthy");

for( k = 0; k < zones.size; k++ )
{
spawners = getEntarray(zones[k].target,"targetname");

if(level.debug == true && zones[k].is_active == true)
{
iprintln("This zone has " + spawners.size + " spawners");
}

return spawners;
}
}
Title: Re: generic zone spawner getting script
Post by: DuaLVII on May 26, 2014, 07:12:15 am
Your probably getting an error because you need to have some kind of blank return in the function like if the for flow control returns nothing it will shoot itself in the head.
Not saying it will happen, but on load it runs itself through those scenario's.

Just need to pop it in there for the scripts convenience.

Code Snippet
Plaintext
get_zone_spawners()
{
spawners = undefined;

zones = getentarray(self.script_noteworthy,"script_noteworthy");

for( k = 0; k < zones.size; k++ )
{
spawners = getEntarray(zones[k].target,"targetname");

if(level.debug == true && zones[k].is_active == true)
{
iprintln("This zone has " + spawners.size + " spawners");
}

return spawners;
}

return false;
}

If not that, Is it an error your receiving or text not showing or is it always returning 0?
Title: Re: generic zone spawner getting script
Post by: daedra descent on May 30, 2014, 12:24:04 pm
Your probably getting an error because you need to have some kind of blank return in the function like if the for flow control returns nothing it will shoot itself in the head.
Not saying it will happen, but on load it runs itself through those scenario's.

Just need to pop it in there for the scripts convenience.

Code Snippet
Plaintext
get_zone_spawners()
{
spawners = undefined;

zones = getentarray(self.script_noteworthy,"script_noteworthy");

for( k = 0; k < zones.size; k++ )
{
spawners = getEntarray(zones[k].target,"targetname");

if(level.debug == true && zones[k].is_active == true)
{
iprintln("This zone has " + spawners.size + " spawners");
}

return spawners;
}

return false;
}

If not that, Is it an error your receiving or text not showing or is it always returning 0?

Nah, the only issue that i get with it is that one or two AI spawn in other zones for whatever reason at the start and i have no real idea why.

Guess i should post the entire code.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;

main()
{
level.debug = true;
level thread zone_think();
}


Zone_think()
{
zones = getEntarray("zones","targetname");
while(1)
{
players = get_players();

for( i = 0; i < players.size; i++ )
{
for( k = 0; k < zones.size; k++ )
{
if(players[i] istouching(zones[k]) )
{
zones[k].is_active = true;
zones[k] activate_spawners();

if(zones[k].is_active == true && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln( "You are in Zone: " + zones[k].script_noteworthy);
}
}
else
{
zones[k].is_active = false;
zones[k] shut_off_spawners();
}
if(zones[k].is_active == true && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln( "You are in Zone: " + zones[k].script_noteworthy);
}
else if(zones[k].is_active == false && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln("Zone: " + zones[k].script_noteworthy + " Not active!");
}

}

}
wait(1);
}
}
activate_spawners()
{
spawners = self get_zone_spawners();

if(isdefined(spawners) )
{
for( k = 0; k < spawners.size; k++ )
{
spawners[k].count = 9999;
}
}
}
shut_off_spawners()
{
spawners = self get_zone_spawners();

if(isdefined(spawners) )
{
for( k = 0; k < spawners.size; k++ )
{
spawners[k].count = 0;
}
}
}

get_zone_spawners()
{
zones = getentarray(self.script_noteworthy,"script_noteworthy");

for( k = 0; k < zones.size; k++ )
{
spawners = getEntarray(zones[k].target,"targetname");

if(level.debug == true && zones[k].is_active == true)
{
iprintln("This zone has " + spawners.size + " spawners");
}

return spawners;
}
}


Title: Re: generic zone spawner getting script
Post by: MakeCents on May 30, 2014, 05:19:55 pm
Nah, the only issue that i get with it is that one or two AI spawn in other zones for whatever reason at the start and i have no real idea why.

Guess i should post the entire code.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;

main()
{
level.debug = true;
level thread zone_think();
}


Zone_think()
{
zones = getEntarray("zones","targetname");
while(1)
{
players = get_players();

for( i = 0; i < players.size; i++ )
{
for( k = 0; k < zones.size; k++ )
{
if(players[i] istouching(zones[k]) )
{
zones[k].is_active = true;
zones[k] activate_spawners();

if(zones[k].is_active == true && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln( "You are in Zone: " + zones[k].script_noteworthy);
}
}
else
{
zones[k].is_active = false;
zones[k] shut_off_spawners();
}
if(zones[k].is_active == true && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln( "You are in Zone: " + zones[k].script_noteworthy);
}
else if(zones[k].is_active == false && isdefined(zones[k].script_noteworthy) && level.debug == true )
{
players[i] iprintln("Zone: " + zones[k].script_noteworthy + " Not active!");
}

}

}
wait(1);
}
}
activate_spawners()
{
spawners = self get_zone_spawners();

if(isdefined(spawners) )
{
for( k = 0; k < spawners.size; k++ )
{
spawners[k].count = 9999;
}
}
}
shut_off_spawners()
{
spawners = self get_zone_spawners();

if(isdefined(spawners) )
{
for( k = 0; k < spawners.size; k++ )
{
spawners[k].count = 0;
}
}
}

get_zone_spawners()
{
zones = getentarray(self.script_noteworthy,"script_noteworthy");

for( k = 0; k < zones.size; k++ )
{
spawners = getEntarray(zones[k].target,"targetname");

if(level.debug == true && zones[k].is_active == true)
{
iprintln("This zone has " + spawners.size + " spawners");
}

return spawners;
}
}

If it is only at the beginning of the game, did you try adding a wait before the the code?
Title: Re: zone spawner getting script
Post by: YaPh1l on May 31, 2014, 11:19:55 am
Are you calling your code after _zombiemode::main(). Before that, get_players() might not return any players.

- Phil.
Title: Re: zone spawner getting script
Post by: daedra descent on May 31, 2014, 11:50:11 am
Are you calling your code after _zombiemode::main(). Before that, get_players() might not return any players.

- Phil.

This isn't for zombiemode. Its for campaign.

This is practically the same as asylum zoning except its broken down into 5 different functions.
Title: Re: zone spawner getting script
Post by: YaPh1l on May 31, 2014, 12:15:20 pm
Okay, then, are you calling this function after the flag "all_players_connected" has been set?

- Phil.
Title: Re: zone spawner getting script
Post by: daedra descent on May 31, 2014, 12:38:40 pm
Okay, then, are you calling this function after the flag "all_players_connected" has been set?

- Phil.

No i didn't. Thought that was only for COOP.
Title: Re: zone spawner getting script
Post by: YaPh1l on May 31, 2014, 01:24:21 pm
Well, I'd assume you would want it to work in Coop too. all_players_connected will also be set in SP, so no harm in waiting for it to be set.

- Phil.