SendAdminCommand
#1

Hello i donґt know how to make a system that if one admin write an admin command, then it will sent message to others administrators. "Admin x used command x." and same for normal players, all typed commands will sent to an administrator
Код:
CMD:matar(playerid, params[])
{
    if(DatosUsuario[playerid][Nivel] >=1 || IsPlayerAdmin(playerid))
    {
        new target,string[256];
        if(sscanf(params, "d", target)) return SendClientMessage(playerid, Amarillo, "[Informaciуn]  Usa:{FFFFFF} /matar (jugador)"), SendClientMessage(playerid, Amarillo, "Este comando sirve para matar a un jugador."), PlayerPlaySound(playerid,1150,0.0,0.0,0.0);
        if(!IsPlayerConnected(target)) return PlayerPlaySound(playerid,1140,0.0,0.0,0.0), SendClientMessage(playerid, Rojo, "[ERROR] {FFFFFF}El jugador no estб conectado."), PlayerPlaySound(playerid,1140,0.0,0.0,0.0);
        SetPlayerHealth(target,0);
        format(string,sizeof(string),"[Informaciуn]{FFFFFF} Administrador {bc277e}%s {FFFFFF}ha matado a {FF9900}%s{FFFFFF}.",NombreJugador(playerid),NombreJugador(target));
        SendClientMessageToAll(Amarillo,string);
        //printf("Administrador %s (%d) ha matado a %s (%d)",NombreJugador(playerid),playerid,NombreJugador(target),target);
    }
    else SendClientMessage(playerid, Rojo,"[Advertencia]{FFFFFF} No estбs autorizado para usar este comando."), PlayerPlaySound(playerid,1140,0.0,0.0,0.0);
    return 1;
}
Here is one admin command...
Reply
#2

You can use foreach or for to iterate through players and send a message if they meet the requested criteria. Example:
pawn Код:
foreach(new i: Player)
{
       if(DatosUsuario[i][Nivel] >=1)
            SendClientMessage(i, color, message);
}
If you use the for version like in the command below, make sure you validate that the player is connected before doing anything else(hint: use IsPlayerConnected).
Reply
#3

Код:
CMD:matar(playerid, params[])
{
    if(DatosUsuario[playerid][Nivel] >= 1 || IsPlayerAdmin(playerid))
    {
        new target,string[256];
        if(sscanf(params, "d", target)) return SendClientMessage(playerid, Amarillo, "[Informaciуn]  Usa:{FFFFFF} /matar (jugador)"), SendClientMessage(playerid, Amarillo, "Este comando sirve para matar a un jugador."), PlayerPlaySound(playerid,1150,0.0,0.0,0.0);
        if(!IsPlayerConnected(target)) return PlayerPlaySound(playerid,1140,0.0,0.0,0.0), SendClientMessage(playerid, Rojo, "[ERROR] {FFFFFF}El jugador no estб conectado."), PlayerPlaySound(playerid,1140,0.0,0.0,0.0);
        SetPlayerHealth(target,0);
		
		for(new i = 0; i < MAX_PLAYERS; i ++)
		{
			if(DatosUsuario[i][Nivel] >= 1 || IsPlayerAdmin(i))
			{
				format(string,sizeof(string),"[Informaciуn]{FFFFFF} Administrador {bc277e}%s {FFFFFF}ha matado a {FF9900}%s{FFFFFF}.",NombreJugador(playerid),NombreJugador(target));
				SendClientMessage(i,Amarillo,string);
			}
			
		}
		
        //printf("Administrador %s (%d) ha matado a %s (%d)",NombreJugador(playerid),playerid,NombreJugador(target),target);
    }
    else SendClientMessage(playerid, Rojo,"[Advertencia]{FFFFFF} No estбs autorizado para usar este comando."), PlayerPlaySound(playerid,1140,0.0,0.0,0.0);
    return 1;
}
Reply
#4

El comando funciona perfectamente, sуlo quiero hacer que cuando un jugador escriba algъn comando, que le salga a los administradores el comando que ha usado.
Ejemplo:
Player1 usa /comandos, mensaje para administradores "Player1 ha usado el comando (comando)"
Reply
#5

Use conditional that I created and insert into callback OnCommandReceived.
Reply
#6

Can you post me the code only to add it to the other commands? im very confused right now
Reply
#7

Код:
for(new i = 0; i < MAX_PLAYERS; i ++)
		{
			if(DatosUsuario[i][Nivel] >= 1 || IsPlayerAdmin(i))
			{
				format(string,sizeof(string),"[Informaciуn]{FFFFFF} Player {bc277e}%s typed: %s.", NombreJugador(playerid), cmdtext);
				SendClientMessage(i,Amarillo,string);
			}
			
		}
Reply
#8

Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)