14.12.2009, 05:06
What you want is a string. Also, if you only want it to show for Admins you'll need to loop through all the players to do this.
When somebody connects to your server, OnPlayerConnect will be called.
Hope I helped.
When somebody connects to your server, OnPlayerConnect will be called.
pawn Код:
public OnPlayerConnect(playerid)
{
new
Name[MAX_PLAYER_NAME], // This is also a form of string, that will be used to store the players name.
string[128]; // Amount of cells (characters) in the string. 128 characters is more then needed, but easier.
GetPlayerName(playerid, Name, sizeof(Name)); // Now the players name that just connecteds name is set under Name.
format(string, sizeof(string), "%s has joined the server!", Name); // %s is used as a string. And the string we used is the "Name" we got earlier. If you didn't use GetPlayerName it won't show.
for (new i=0; i<MAX_PLAYERS; i++) // Loop
{
if (IsPlayerConnected(i) && IsPlayerAdmin(i)) // If any player is connected, and an admin they will get this message.
{
SendClientMessage(i, 0xFFFFFFFF, string); // Client message to send the string. (In white)
}
}
return true;
}
public OnPlayerDisconnect(playerid, reason)
{
new
Name[MAX_PLAYER_NAME],
string[128];
GetPlayerName(playerid, Name, sizeof(Name)); // Get the players name once again.
switch (reason) // Toggle between reasons how the player disconnected.
{
case 0: format(string, sizeof(string), "%s has left the server. [Timeout]", Name);
case 1: format(string, sizeof(string), "%s has left the server. [Left]", Name);
case 2: format(string, sizeof(string), "%s has left the server. [Kick/Ban]", Name);
}
for (new i=0; i<MAX_PLAYERS; i++) // Loop
{
if (IsPlayerConnected(i) && IsPlayerAdmin(i)) // If any player is connected, and an admin they will get this message.
{
SendClientMessage(i, 0xFFFFFFFF, string); // Client message to send the string. (In white)
}
}
return true;
}