[Tutorial] How to execute a Joining Counter [C-Projects]
#1

How to create a Joining Counter

Most servers will not have a feature that limits the ability for you to be able to select and choose how many people you would like to join your server at a time. This feature I will be explaining how you will be able to reject players if to many have joined all at once.

Please follow the simple steps below and be warned that this code has not been tested, so use at your own risk.


Step 1: Creating the Variable Required

The variables you will need will be around 3 - 4 that will allow the server to pinpoint and give the correct player the correct value.

Код:
#undef MAX_PLAYERS
#define MAX_PLAYERS 10

#define MAX_JOINING 5

new PlayersJoining;
Step 2: Creating the system itself

This code you will need to alter and place where you have your Players connecting too. Is will refuse if there are more then 5 players trying to connect and kick the ones that are waiting to join.

Код:
public OnPlayerConnect(playerid)
{
	for(new i=0; i<MAX_PLAYERS; i++)
	{
		if(PlayersJoining == 0)
		{
			if(IsPlayerConnected(i))
			{
				PlayersJoining++;
				return 1;
			}
		}
		else if(PlayersJoining == MAX_JOINING)
		{
			if(IsPlayerConnected(i))
			{
				SendClientMessage(i, -1, "Server Notice: You cannot join the server yet, due to high demand of connections");
				Kick(i);
				return 1;
			}
		}
	}
	return 1;
}

public OnPlayerSpawn(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		PlayersJoining--;
	}
	return 1;
}
This is kind of my first sort of tutorial to explain how to make this, not going into every detail but when you see it you will under what section does what.
Reply


Messages In This Thread
How to execute a Joining Counter [C-Projects] - by Ciandlah - 18.05.2014, 03:12
Re: How to execute a Joining Counter [C-Projects] - by Lordzy - 18.05.2014, 05:11

Forum Jump:


Users browsing this thread: 1 Guest(s)