/admin command
#6

pawn Code:
COMMAND:admin(playerid, params[])
{
    // Setup local variables
    new OtherPlayer, Message[128], Msg1[128], Msg2[128], YourName[24], OtherPlayerName[24];

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/admin", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        if (sscanf(params, "us[128]", OtherPlayer, Message)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/admin <OtherPlayer> <Message>\"");
        else
        {
            // Check if that other player is online
            if (IsPlayerConnected(OtherPlayer))
            {
                // Check if the player is admin
                if (IsPlayerAdmin(OtherPlayer))
                {
                    // Get both names
                    GetPlayerName(playerid, YourName, sizeof(YourName));
                    GetPlayerName(OtherPlayer, OtherPlayerName, sizeof(OtherPlayerName));
                    // Construct the message that is sent to yourself
                    format(Msg1, 128, "{808080}PM to %s{FFFFFF}: %s", OtherPlayerName, Message);
                    // Construct the message that is sent to the other player
                    format(Msg2, 128, "{A0A0A0}PM by %s{FFFFFF}: %s", YourName, Message);
                    // Send the messages
                    SendClientMessage(playerid, 0xFFFFFFFF, Msg1);
                    SendClientMessage(OtherPlayer, 0xFFFFFFFF, Msg2);
                }
                else
                    SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}He isn't admin");
            }
            else
                SendClientMessage(playerid, 0xFF0000FF, "Player is not online");
        }
    }
    else
     return 0;

    // Let the server know that this was a valid command
    return 1;
}
Reply


Messages In This Thread
/admin command - by Trucker[UK] - 28.08.2011, 02:00
Re: /admin command - by =WoR=Varth - 28.08.2011, 02:28
Re: /admin command - by Trucker[UK] - 28.08.2011, 02:37
Re: /admin command - by =WoR=Varth - 28.08.2011, 02:52
Re: /admin command - by Trucker[UK] - 28.08.2011, 02:53
Re: /admin command - by =WoR=Varth - 28.08.2011, 09:18

Forum Jump:


Users browsing this thread: 2 Guest(s)