I'm trying to make a script that counts up 1 everytime the amount of players alive is 1. The iprintln says 1 everytime though, any help getting it working?
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
is setting it back to 0 everytime this function is called, but also this variable does not exist outside of this functions name space, make it global by applying it to level
is setting it back to 0 everytime this function is called, but also this variable does not exist outside of this functions name space, make it global by applying it to level
Post the entire function then. Can't help you with what little information your providing.
Edit: Just to clarify/point out, players is an array and you can never attach anything directly to an array, only each individual entities that make up the array which you can get by using an index, key, or both(more advanced stuff).
Last Edit: June 09, 2015, 06:52:51 am by daedra descent
you just need to make sure you declare it before referencing it, similar to the original problem
I meant you can store the variable for each players using different methods than using get_players(), just takes longer and uses more code than is necessary.
Last Edit: June 09, 2015, 07:16:01 am by daedra descent
if ( !isDefined( players[i].rounds_won) ) { players[i].rounds_won = 0; }
if( players_alive == 1 ) { if( !is_player_valid(players[i]) ) { iprintlnbold("You have won this round!"); players[i].rounds_won++; iprintln("Rounds Won: " + players[i].rounds_won); } else { iprintlnbold("You have been given another chance"); }
I meant post the entire function i meant post everything, even the head and where your variables are coming from because from your original code i don't know where players_alive is coming from.
But regardless i rewrote the function which should work:
if(!is_player_valid(players[i])) { iprintlnbold("You have won this round!"); players[i].rounds_won++; iprintln("Rounds Won: " + players[i].rounds_won); } else iprintlnbold("You have been given another chance");
if( players_alive == 1 ) { for (i = 0; i < players.size; i++) { if( is_player_valid(players[i]) ) { iprintlnbold("You have won this round!"); players[i].rounds_won++; iprintln("Rounds Won: " + players[i].rounds_won); } else { iprintlnbold("You have been given another chance"); } }
zombs = getaiarray("axis"); for(i=0;i<zombs.size;i++) { zombs[i] delete(); //removes all currently spawned in zombies }
maps\_zombiemode_powerups::powerup_round_start(); //restarts the amount of powerups you can earn this round array_thread( players, maps\_zombiemode_blockers_new::rebuild_barrier_reward_reset ); //restarts your barrier points this round level thread [[level.round_spawn_func]](); //makes the amount of zombies restart to its original amount for the round
players = get_players(); for( i = 0; i < players.size; i++ ) //respawns you back in and gives you your weapons back { players[i] spectator_respawn(); players[i] [[level.spawnPlayer]](); while(1) { if(players[i] hasWeapon("zombie_colt")) { players[i] takeAllWeapons(); players[i] maps\_laststand::laststand_giveback_player_weapons(); if( isDefined( players[i].has_altmelee ) && players[i].has_altmelee ) { players[i] SetPerk( "specialty_altmelee" ); } if (isDefined(level.script) && players[i].score < 5000) { players[i].old_score = players[i].score; players[i].score = 5000; players[i] maps\_zombiemode_score::set_player_score_hud(); } level thread award_grenades_for_survivors(); //get 2 extra grenades when you spawn back in, optional break; } wait(0.05); } }
Here is all the code that you need. The print in counts up currectly, the only thing that doesnt work is the last part. The code is not waiting for rounds_won to equal 3 even though thats what is coded, it is ending the game no matter what.
Here is all the code that you need. The print in counts up currectly, the only thing that doesnt work is the last part. The code is not waiting for rounds_won to equal 3 even though thats what is coded, it is ending the game no matter what.
... because there isn't anything to prevent it from looping again - assuming that this whole function is looped somewhere or is called more than once - it'll just keep adding to each players round_won var without really stopping.
... because there isn't anything to prevent it from looping again - assuming that this whole function is looped somewhere or is called more than once - it'll just keep adding to each players round_won var without really stopping.
Try adding:
Code Snippet
Plaintext
level waittill( "between_round_over" );
right before this:
Code Snippet
Plaintext
if( players_alive == 1 )
But it's in a mod where the round never ends, it's round 15 with a very high amount of zombies, and when theres only one player left the round restarts and all the other players spawn back in.
But it's in a mod where the round never ends, it's round 15 with a very high amount of zombies, and when theres only one player left the round restarts and all the other players spawn back in.
and your testing this in SP, correct? That would be why it isn't working - the condition would always be true because there is always one player in SP and they are always valid players.
Just add a size comparison to determine if the game is coop or not:
Code Snippet
Plaintext
if(players.size > 1 && players_alive == 1 )
This would make sure that it only runs if there are more than one player in the game. Your going to have to test the script in COOP though - no real way around it.
Last Edit: June 10, 2015, 02:46:05 am by daedra descent