SendClientMessage To Admins
#1

Hi, when my players type /ls I want a message to be sent to rcon admins saying someone has teleported.

pawn Код:
if (strcmp("/ls", cmdtext, true, 10) == 0)
    {
            if(IsPlayerAdmin(playerid))    // Please tell me how to do this!
            {
                SendClientMessage(playerid, COLOR_WHITE, "Someone Has Teleported To LS");
            }

            RemovePlayerFromVehicle(playerid);
            carmenuENABLED[playerid] = 1;

            if(IsPlayerInAnyVehicle(playerid))
            {
                new getvehicle = GetPlayerVehicleID(playerid);
                SetVehiclePos(getvehicle, 1452.6721,-2424.0176,13.5547);
            }
            else
            {
                SetPlayerPos(playerid, 1445.8578,-2416.9778,13.8681);
            }
            return 1;
    }
The code above will only send the teleport message to admins if an admin typed the command.

Please can someone help me!

Thanks in advance
Reply
#2

pawn Код:
for (new i=0;i<MAX_PLAYERS;i++)
{
    if (IsPlayerConnected(i))
    {
        if (IsPlayerAdmin(i))
        {
            SendClientMessage(i, COLOR_WHITE, "Someone Has Teleported To LS");
        }
    }
}
Reply
#3

pawn Код:
if (strcmp("/ls", cmdtext, true, 10) == 0)
    {
            SendAdminMessage(COLOR_WHITE, "Someone Has Teleported To LS");

            RemovePlayerFromVehicle(playerid);
            carmenuENABLED[playerid] = 1;

            if(IsPlayerInAnyVehicle(playerid))
            {
                new getvehicle = GetPlayerVehicleID(playerid);
                SetVehiclePos(getvehicle, 1452.6721,-2424.0176,13.5547);
            }
            else
            {
                SetPlayerPos(playerid, 1445.8578,-2416.9778,13.8681);
            }
            return 1;
    }
pawn Код:
forward SendAdminMessage(color, string[]);
public SendAdminMessage(color, string[])
{
    foreach(Player, i)
    {
        if(IsPlayerAdmin(i))
        {
            SendClientMessage(i, color, string);
        }
    }
}
Reply
#4

pawn Код:
if (strcmp("/ls", cmdtext, true, 10) == 0)
    {
            for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) //Loops through all connected players
            {
                if(IsPlayerAdmin(i)) //Check if he/she is logged in at rcon
                {
                    SendClientMessage(i, COLOR_WHITE, "Someone Has Teleported To LS"); //sends the message to all who is logged into rcon
                }
            }

            RemovePlayerFromVehicle(playerid);
            carmenuENABLED[playerid] = 1;

            if(IsPlayerInAnyVehicle(playerid))
            {
                new getvehicle = GetPlayerVehicleID(playerid);
                SetVehiclePos(getvehicle, 1452.6721,-2424.0176,13.5547);
            }
            else
            {
                SetPlayerPos(playerid, 1445.8578,-2416.9778,13.8681);
            }
            return 1;
    }
Reply
#5

thats great! Thanks to everyone who replyed
Reply
#6

also you can
pawn Код:
new name[MAX_PLAYER_NAME], string[50];
format(string,sizeof(string), "%s has teleported to LS!", name);
GetPlayerName(playerid, name, sizeof(name));
above the for loop then
pawn Код:
SendClientMessage(i, COLOR_WHITE, string); //this inside the loop...replacing the other 1
So you can see the name of the one that teleported instead of just "someone" being teleported
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)