[Tutorial] Making a simple admin chat command
#1

Okay... Let's go:
We would use zcmd for this tutorial.
We first would create a stock for use in the future...

pawn Код:
stock AdminChat(level, Msg[]) //Level is the minium admin what we must have to see the command, and msg[] is the string.
{
    for(new i = 0; i < MAX_PLAYERS)//Loop through all players, you can use foreach if you prefer.
    {
        if(IsPlayerConnected(i) && Info[i][Admin] => level)//If the player are connected and the Admin is equal to or greater.
        //Change 'Info[i][Admin]' for your variable.
        {
            SendClientMessage(i, -1, Msg);//Send to all players the 'Msg'
        }
    }
    return 1;
}
Okay, we now can use AdminChat(level, Msg[]);
Now the command...


pawn Код:
CMD:admin(playerid, params[])
{
    new string[172];//The string...
    if(isnull(params)) return SendClientMessage(playerid, -1, "Please use /admin [Message]"); //If the player only send '/admin'.
    new PlayerName[MAX_PLAYER_NAME+1]; //The string to store the name.
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); //We get the player name.
    format(string, sizeof(string), "AdminChat %s: %s", PlayerName, params); //The final message...
    AdminChat(1, string); // The minium admin level is 1, and the message is the string.
    return 1;
}
Sorry for the bad english. this is my first tutorial so only I wait for constructive comments or doubts. Thank you
Reply
#2

Not bad ...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)