UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Teleport Zombies

broken avatar :(
Created 10 years ago
by nabaro
0 Members and 1 Guest are viewing this topic.
2,753 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 January 2014
Last active: 3 years ago
Posts
143
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
nabaro's Groups
nabaro's Contact & Social Linksgamerblast11chelseafan122099nabaro
Don't have access to my mod tools right now, but can you guys see anything wrong with this script I just typed up which teleports zombies to a secret area if all the players are in it? Thanks in advance!

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

main()
{
flag_wait("all_players_connected");
players = get_players();
level.in_secret_area = 0;
level.all_players_in_secret_area = players.size;
for(i = 0; i < players.size; i++)
{
players[i] thread check_secret_area();
}
thread zombie_teleport();
}

check_secret_area()
{
secret_area = getEnt("secret_area", "targetname");
self.in_secret_area = 0;
while(1)
{
if(self isTouching(secret_area))
{
if(self.in_secret_area = 0)
{
level.in_secret_area = level.in_secret_area + 1;
wait(0.05);
}
else
{
wait(0.05);
}
self.in_secret_area = 1;
}
else
{
if(self.in_secret_area = 1)
{
level.in_secret_area = level.in_secret_area - 1;
self.in_secret_area = 0;
wait(0.05);
}
else
{
wait(0.05);
}
}
}
}

zombie_teleport()
{
tele_spot_1 = getEnt("tele_spot_1", "targetname");
tele_spot_2 = getEnt("tele_spot_2", "targetname");
tele_spot_3 = getEnt("tele_spot_3", "targetname");
tele_spot_4 = getEnt("tele_spot_4", "targetname");
tele_location = undefined;
while(1)
{
if(level.in_secret_area == level.all_players_in_secret_area)
{
zombies = getaispeciesarray("axis");
for(j = 0; j < zombies.size; j++)
{
if(level.in_secret_area == level.all_players_in_secret_area)
{
rand = randomintrange(1, 5);
if(rand == 1)
{
tele_location = tele_spot_1;
wait(0.05);
}
else if(rand == 2)
{
tele_location = tele_spot_2;
wait(0.05);
}
else if(rand == 3)
{
tele_location = tele_spot_3;
wait(0.05);
}
else if(rand == 4)
{
tele_location = tele_spot_4;
wait(0.05);
}
zombies[j] forceteleport(tele_location.origin, tele_location.angles);
playfx(level._effect["powerup_on"], tele_location.origin);
wait(1);
}
else
{
wait(0.05);
break;
}
}
}
else
{
wait(0.05);
}
}
}
      
   
EDIT: Added waits in the while loops. If I missed any, please let me know.
EDIT2: For clarification, the area is attached to the playable area until all players are on it.
Last Edit: May 28, 2014, 06:35:20 pm by nabaro
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 5 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
Signature
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
1) No wait in your while loops.
I may check when I get back for more but someone else may see some if there are any other things wrong.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 January 2014
Last active: 3 years ago
Posts
143
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
nabaro's Groups
nabaro's Contact & Social Linksgamerblast11chelseafan122099nabaro
Thanks, I'll modify it in the OP.
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 5 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
Code Optimize:
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;
#include maps\_anim;

main()
{
flag_wait("all_players_connected");
players = get_players();
level.in_secret_area = 0;
level.all_players_in_secret_area = players.size;
for(i = 0; i < players.size; i++)
players[i] thread check_secret_area();
thread zombie_teleport();
}

check_secret_area()
{
secret_area = getEnt("secret_area", "targetname");
self.in_secret_area = 0;
while(1)
{
if(self isTouching(secret_area))
{
if(self.in_secret_area == 0)
level.in_secret_area += 1;
self.in_secret_area = 1;
}
else
{
if(self.in_secret_area == 1)
level.in_secret_area -= 1;
self.in_secret_area = 0;
}
wait .05;
}
}

zombie_teleport()
{
for( i = 1; i < 5; i++ )
TeleSpot[i] = getEnt( "tele_spot_" + i, "targetname" );
tele_location = undefined;
while(1)
{
if(level.in_secret_area == level.all_players_in_secret_area)
{
zombies = getaispeciesarray("axis");
if(level.in_secret_area == level.all_players_in_secret_area)
{
rand = randomintrange(1, 5);
if(rand == 1)
tele_location = TeleSpot[1];
else if(rand == 2)
tele_location = TeleSpot[2];
else if(rand == 3)
tele_location = TeleSpot[3];
else if(rand == 4)
tele_location = TeleSpot[4];
for(j = 0; j < zombies.size; j++)
zombies[j] forceteleport(tele_location.origin, tele_location.angles);
playfx(level._effect["powerup_on"], tele_location.origin);
wait(1);
}
else
break;
}
wait .05;
}
}
Last Edit: May 28, 2014, 08:27:11 pm by PROxFTW
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 January 2014
Last active: 3 years ago
Posts
143
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
nabaro's Groups
nabaro's Contact & Social Linksgamerblast11chelseafan122099nabaro
Thanks, I was thinking about using an array for the random locations. As I'm thinking about the logic, I realized I made a mistake: level.all_players_in_secret_area should be equal to the number of players alive, not the number of players in general. How do I do that?
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 5 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
This should work.
Code Snippet
Plaintext
level.all_players_in_secret_area = ( GetPlayers().size -  maps\_laststand::player_num_in_laststand() );
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 January 2014
Last active: 3 years ago
Posts
143
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
nabaro's Groups
nabaro's Contact & Social Linksgamerblast11chelseafan122099nabaro
Is there a similar variable for players dead, not downed?
Marked as best answer by nabaro 10 years ago
broken avatar :(
×
broken avatar :(
Location: usYork, SC
Date Registered: 15 March 2014
Last active: 5 years ago
Posts
214
Respect
Forum Rank
Mr. Elemental
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
WaW Scriptor
×
PROxFTW's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
PROxFTW's Contact & Social LinksPROxFTWPROxFTWPROxFTWPROxFTW
Oh sorry forgot it only registers down.
Code Snippet
Plaintext
level.all_players_in_secret_area = ( ( GetPlayers().size + 1 ) - GetPlayersAlive() );
GetPlayersAlive()
{
      num = 0;
      players = GetPlayers();
        for( i = 0; i < players.size; i++ )
       if( players[i].is_zombie )
num += 1;
       return num;
}
Last Edit: May 28, 2014, 09:22:23 pm by PROxFTW
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 January 2014
Last active: 3 years ago
Posts
143
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
nabaro's Groups
nabaro's Contact & Social Linksgamerblast11chelseafan122099nabaro
Thanks so much for all your help!

 
Loading ...