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

Randomization player


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Hennesy
Member
Join Date: Nov 2018
Location: Czech Republic
Old 08-04-2021 , 04:32   Randomization player
Reply With Quote #1

Hello everyone, I apologize for the English, please tell me how can I make a random distribution of roles?

I need to call the function, implement the issuance of roles for the players.

There is a certain but, the role is assigned g_iRole [iClient] = Role_Name

There is a counter of how many roles need to be given to players, that is, based on the number of roles, it is necessary to randomly assign them to the players.

my counter roles:
Code:
void CalculateRoles()
{
	int iTotalPlayers = 0;
	
	// roleOne, roleTwo, roleThree, roleFour // global int
	
	for(int i = 1; i <= MaxClients; ++i)
	{
		if(IsClientInGame(i) && IsPlayerAlive(i))
		{
			iTotalPlayers++;
		}
	}

	roleOne = iTotalPlayers / 6;
	roleTwo = iTotalPlayers / 10;
	roleThree = (iTotalPlayers > 2) ? (iTotalPlayers / 5) :  (iTotalPlayers > 1 ? 1 : 0);
	roleFour = iTotalPlayers - roleOne - roleTwo - roleThree;
}
I have a timer at the end of which I need to assign roles. By calling a function such as InitRoles (), I'm not so much a pro yet, I can't figure out how to better implement it. I ask for help

Thank you very much for those who can help

Last edited by Hennesy; 08-04-2021 at 04:38.
Hennesy 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 00:48.


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