12.08.2018, 22:09
Whenever he comes with 0 players connected it says "uh, looks like the server is empty... except you" ?
Next time search.
Here you go: https://sampforum.blast.hk/showthread.php?tid=168818 |
GetOnlinePlayers();
if(OnLine == 1) ...
pawn Код:
|
if(GetOnlinePlayers()>5){Commence} else if{Don't}
/*
Script Documentation:
Made by: brauf
Tested: Yes
*/
#include <a_samp>
new PlayersOnline; // this variable stores a integer of the players online
GetPlayersOnServer() // function to get players on server
{
PlayersOnline = 0; // reset online players each time when trying to fetch it otherwise "PlayersOnline" will just keep increasing each time (++) with each check
for(new i; i < MAX_PLAYERS; i++) // do a loop of all player slots available (1, 2, 3 - 1000), if player slot 1 or 2 or 3 has a valid player connected (IsPlayerConnected) then increase "PlayersOnline" by 1 (++)
{
if(IsPlayerConnected(i)) // a check to see if player is online on that id
{
PlayersOnline++; // increase "PlayersOnline" by 1 if there is a online player on
return PlayersOnline; // return "PlayersOnline" which tells the server how much players are on
}
}
return PlayersOnline; // return "PlayersOnline" which stores the value of how much players are on
}
public OnPlayerConnect(playerid)
{
GetPlayersOnServer(); // execute this function "OnPlayerConnect" so when a player logs in, it tries to detect how much players are on
if(PlayersOnline == 1) // if online players = 1, then there is only 1 player online
{
SendClientMessage(playerid, -1, "Looks like the server is empty, except you."); // send a message
}
return 1;
}