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

Check For Players Alive?

broken avatar :(
Created 9 years ago
by jbird
0 Members and 1 Guest are viewing this topic.
2,592 views
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 13 May 2014
Last active: 3 years ago
Posts
167
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
×
jbird's Groups
I'm trying to make a script that ends the game when only one player is alive. Currently it ends the game no matter what after round 1

Code Snippet
Plaintext
spectators_respawn()
{
level endon( "between_round_over" );

if( !IsDefined( level.zombie_vars["spectators_respawn"] ) || !level.zombie_vars["spectators_respawn"] )
{
return;
}

if( !IsDefined( level.custom_spawnPlayer ) )
{
// Custom spawn call for when they respawn from spectator
level.custom_spawnPlayer = ::spectator_respawn;
}

while( 1 )
{
players_alive = 0;

players = get_players();
for( i = 0; i < players.size; i++ )
{
if( IsAlive( players[i] ))
{
players_alive++;
}

if( players[i].sessionstate == "spectator" && players_alive > 1 )
{
players[i] [[level.spawnPlayer]]();
//if( isDefined( players[i].has_altmelee ) && players[i].has_altmelee )
//{
// players[i] SetPerk( "specialty_altmelee" );
//}
if (isDefined(level.script) && level.round_number > 6 && players[i].score < 1500)
{
players[i].old_score = players[i].score;
players[i].score = 1500;
players[i] maps\_zombiemode_score::set_player_score_hud();
}
}
if( players_alive == 1 )
{
level notify( "end_game" );
}
else
{
return;
}
}

wait( 1 );
}
}
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 4 years ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
If for some reason players_alive is not defined it will pass and if it equals 1 then it will also pass and level notify("end_game").

Code Snippet
Plaintext
			if( players_alive == 1 )
{
level notify( "end_game" );
}

try adding a print or two like this

Code Snippet
Plaintext
			iprintlnbold(players_alive, " players alive");
if( players_alive == 1 )
{
level notify( "end_game" );
}
iprintlnbold(isdefined(players_alive), " players_alive defined");


Then adjust things from there. Most likely players_alive == 1 and it is ending the game after round one because you put it in the spectators_respawn() function that I assume runs after the round ends and respawns the spectators.

With all that aside. Why would you want to do that? And what are your plans for single player games? And do you only want to end if when the round ends only one player is alive or... or if all players go down but one you want to end the game at any time? Or they actually have to die and if all die but one at any time the game ends?
Last Edit: May 22, 2015, 03:22:13 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 3 weeks ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
You can also do,
Code Snippet
Plaintext
if(player.sessionstate == "spectator")
{
        // Dead in coop
}
Obviously, this will return true when a player bleeded out in coop laststand.
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 13 May 2014
Last active: 3 years ago
Posts
167
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
jbird's Groups
I found a way to do it by looking in Black Ops 1 scripts.
Code Snippet
Plaintext
if( !(players[i] maps\_laststand::player_is_in_laststand()) && !(players[i].sessionstate == "spectator") )
{
players_alive++;
}
It checks to see if the player isnt downed or spectating and then it counts them as alive.
This is for a competitive free for all zombies mod meant only for coop. If there is one player alive and they finish off the round, then they win. (like in Grief mode)
Marked as best answer by jbird 9 years ago
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 4 weeks ago
Posts
327
Respect
Forum Rank
Perk Hacker
Primary Group
Community Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
Signature
My Custom Zombie Maps:

- Nazi zombie Legion
- City of Hell
- The Abandoned Mine
- The Last Undead House (Finished)

more custom zombie maps coming soon
×
gamer9294's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
gamer9294's Contact & Social Links
I found a way to do it by looking in Black Ops 1 scripts.
Code Snippet
Plaintext
if( !(players[i] maps\_laststand::player_is_in_laststand()) && !(players[i].sessionstate == "spectator") )
{
players_alive++;
}
It checks to see if the player isnt downed or spectating and then it counts them as alive.
This is for a competitive free for all zombies mod meant only for coop. If there is one player alive and they finish off the round, then they win. (like in Grief mode)


okay but I'm also thinking that you need to add a code in the if()  line like about:

is_player_valid(players)

sample:

Code Snippet
Plaintext
if( is_player_valid(players[i]) && !(players[i] maps\_laststand::player_is_in_laststand()) && !(players[i].sessionstate == "spectator") )
{
players_alive++;
}

because if we playing a game and there total 4 players and when 1 player leave the game and there are 3 players then I think the 4th player is not removed correctly from the game

you can also see it on the hud score that the points not on the correct location are.


I'm only trying to helping :)


best regards,
gamer9294
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 13 May 2014
Last active: 3 years ago
Posts
167
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
jbird's Groups
What does is_player_valid mean exactly?
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21'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.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
like he said it alows for player disconnections

Then bugging out will not clear their values properly, it checks for that, i think
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 4 weeks ago
Posts
327
Respect
Forum Rank
Perk Hacker
Primary Group
Community Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
×
gamer9294's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
gamer9294's Contact & Social Links
What does is_player_valid mean exactly?


Yes what Harry Bo21 said:

Quote
like he said it alows for player disconnections

Then bugging out will not clear their values properly, it checks for that, i think


is correct :)   that is what it does :)



best regards,
Gamer9294
broken avatar :(
×
broken avatar :(
Location: nlApeldoorn
Date Registered: 17 December 2013
Last active: 1 year ago
Posts
1,187
Respect
1,404Add +1
Forum Rank
Zombie Colossus
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
It aint much, if it aint Dutch
Signature
×
BluntStuffy's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
Oil Rig Beta Access
Oil Rig Beta Access
BluntStuffy's Contact & Social LinksBluntstuffy@BluntZombieBluntStuffyStuffyZombie
All the stuff it checks: ( _zombiemode_utility )


Code Snippet
Plaintext
is_player_valid( player )
{
if( !IsDefined( player ) )
{
return false;
}

if( !IsAlive( player ) )
{
return false;
}

if( !IsPlayer( player ) )
{
return false;
}

if( player.is_zombie == true )
{
return false;
}

if( player.sessionstate == "spectator" )
{
return false;
}

if( player.sessionstate == "intermission" )
{
return false;
}

if(  player maps\_laststand::player_is_in_laststand() )
{
return false;
}

if ( player isnotarget() )
{
return false;
}

return true;
}
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 13 May 2014
Last active: 3 years ago
Posts
167
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
×
jbird's Groups
So then all I really need is "is_player_valid(players)" because it checks everything else
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21'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.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
seems that way ;)

 
Loading ...