Raised This Month: $ Target: $400
 0% 

A type of global variable


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
gregws
Member
Join Date: Aug 2013
Old 08-25-2013 , 01:09   A type of global variable
Reply With Quote #1

Hi guys,

I'm wanting to check to see how many people are in the game at the start of each round. But also allow all functions to have access to this variable at any time.
Code:
stock GetRealClientCount( bool:inGameOnly = true ) {
 	new clients = 0;
 	for( new i = 1; i <= GetMaxClients(); i++ ) {
 		if( ( ( inGameOnly ) ? IsClientInGame( i ) : IsClientConnected( i ) ) && !IsFakeClient( i ) ) {
 			clients++;
 		}
 	}
 	return clients;
 }
I know how to call this once at round start, but I'm not sure how to allow all the following functions access to it. Eg.

Code:
roundStart()
{
pCount = GetRealClientCount();
}

anotherFunction()
{
blah blah blah
doSometingWithpCount(pCount);
}
gregws is offline
 



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 19:10.


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