Raised This Month: $32 Target: $400
 8% 

Solved [ANY]How can I loop through active players in turn?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Morning
Member
Join Date: May 2021
Old 11-27-2022 , 17:59   [ANY]How can I loop through active players in turn?
Reply With Quote #1

Hi!

I'm trying to loop through active players in turn in order to determine whos turn it is next, but I'm having a bit of a logic block. I could be trying to do something really stupid here, can anyone help me out?

Code:
int nextplayer = 1;
bool lastplayer = false;

void GetNextPlayer()
{
bool nextplayerset = false;
if(lastplayer)
	{
	nextplayer = 1;
	}
for(int i = 1; i <= MaxClients; i++)
	{
	if(i > 0 && i <= MaxClients && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && !IsFakeClient(i) && !nextplayerset)
		{
		nextplayer = i;
		nextplayerset = true;
		}
	if(i > 0 && i <= MaxClients && IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i) && !IsFakeClient(i) && nextplayerset)
		{
		lastplayer = false;
		}
	else
		{
		lastplayer = true;
		}
	}
}

void GiveSomethingToPlayer()
{
	GetNextPlayer();
	GiveToPlayer(nextplayer);
}

Last edited by Morning; 11-28-2022 at 07:57.
Morning is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode