CMD:rconchat(playerid, params[]) // this is called when someone in the game uses the command /rconchat
{ // opens the code
return 1; // returns a value of true
} // closes the code
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
/* The explanation mark before the IsPlayerAdmin means NOT. So basically, if(IsPlayerNotAnAdmin.
And the (playerid) is the person who uses the command. The return of the SendClientMessage is
sending the message with the color of 0xFFFFFFFF saying that you're not an RCON admin.*/
return 1;
}
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
new ChatText[100], string[130], AdminName[MAX_PLAYER_NAME];
/* This is declaring 3 new public variables, the name of the admin with AdminName with an array
of the MAX_PLAYER_NAME and the ChatText, which means how much that person can type.
The string[130] adds up so it means how much it is altogether, because we can't use
variables with SendClientMessage, you'll see and understand what I mean after. */
return 1;
}
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
new ChatText[100], string[130], AdminName[MAX_PLAYER_NAME];
if(sscanf(params, "s[100]", ChatText)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
/* This line is basically telling the script that if the person does not type anything,
then it will return that specific message of the "Correct usage: ...". The s[100] declares
a string that we'll be using, and the 100 is the character count as in the ChatText.
More information about sscanf can be found on the sscanf topic, just ****** it. */
return 1;
}
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
new ChatText[100], string[130], AdminName[MAX_PLAYER_NAME];
if(sscanf(params, "s[100]", ChatText)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
GetPlayerName(playerid, AdminName, sizeof(AdminName));
/* This will simply get the playerid's name, remember, the playerid is the person
who send the command. The AdminName is the variable that we declared above
with the array of MAX_PLAYER_NAME, and the sizeof(AdminName) means that
the size of the AdminName is MAX_PLAYER_NAME which is already defined
in a_samp.inc */
return 1;
}
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
new ChatText[100], string[130], AdminName[MAX_PLAYER_NAME];
if(sscanf(params, "s[100]", ChatText)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
GetPlayerName(playerid, AdminName, sizeof(AdminName));
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
{
}
}
}
/* This code here is basically telling the script to loop all the connected players and
check if they're logged in as RCON admins, and if they are, it will do Step 7 */
return 1;
}
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
new ChatText[100], string[130], AdminName[MAX_PLAYER_NAME];
if(sscanf(params, "s[100]", ChatText)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
GetPlayerName(playerid, AdminName, sizeof(AdminName));
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerAdmin(i))
{
format(string, sizeof(string), "RCON CHAT: %s said: %s", AdminName, ChatText);
SendClientMessage(i, 0xFFFFFFFF, string);
/* This code here will send all the RCON'ly online admins the text
that we formatted in the string, we use a string because SendClientMessage
simply won't support variables, i.e. the variables AdminName and the ChatText
that we used. */
}
}
}
return 1;
}
if(sscanf(params, "s[100]", ChatText)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
really good tut thank you so much where can i learne more about the loop?
|
CMD:rconchat(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not an RCON admin.");
if(isnull(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /rconchat [text]");
new string[144], AdminName[MAX_PLAYER_NAME];
GetPlayerName(playerid, AdminName, sizeof(AdminName));
format(string, sizeof(string), "RCON CHAT: %s said: %s", AdminName, params);
foreach(new i : Player) if(IsPlayerAdmin(i)) SendClientMessage(i, 0xFFFFFFFF, string);
return 1;
}