18.05.2014, 03:12
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.
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.
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.
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;
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; }