Sendmessagetoadmins
#1

Howdy people, i've got a question i got this function:

pawn Код:
stock SendMessageToAdmins(text[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(PInfo[i][Level] > 1)
        {
            SendClientMessage(i, blue, text);
        }
    }
}
pawn Код:
SendMessageToAdmins(msg);
I use it for the /a chat but i was wondering, could i also use this for like sending CMDS to the admins like

Код:
Admin Biess has used the command SETLEVEL
Код:
Admin Biess has banned user Test
If someone could make it like that i'd be happy!
Reply
#2

One alternative to this is:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(PInfo[playerid][Level] > 1)
    {
        SendCommandToAdmins(playerid, cmdtext);
    }
    return 0;
}

stock SendCommandToAdmins(playerid, command[])
{
    new string[], PLAYERSNAME[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PLAYERSNAME, MAX_PLAYER_NAME);
    format(string,sizeof(string),"Admin %s Has Used The Command: %s",PLAYERSNAME,command);
    SendMessageToAdmins(string);
    return 1;
}
Otherwise you can add it individually to all commands.
Like:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/testcommand", true) == 0) //Or ZCMD, DCMD, whatever...
    {
        SendCommandToAdmins(playerid, "testcommand");
        return 1;
    }
    return 0;
}
Reply
#3

Or like this
Код:
forward SendAdminMessage(color, string[]);
Код:
public SendAdminMessage(color, string[])
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i))
		{
		    if(PlayerInfo[i][pAdmin] >= 1)
		    {
				SendClientMessage(i, color, string);
			}
		}
	}
}
Код:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
	if(PlayerInfo[playerid][pAdmin] < 1338) return SCM(playerid,COLOR_RED,"{B3B3B3}[{FF0000}ERROR!{B3B3B3}] You are not admin!");
	else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_RED,"Use: {FFFFFF}/makeadmin[Nick/ID] [level 1-1338]");
	else if (value < 0 || value > 1338) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> [ERROR] {FFFFFF}Unkown level! [0-1338]");
	else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}>> [ERROR] {FFFFFF}WrongID!");
	else
	{
	   	new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
	   	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	    GetPlayerName(pID, tName, MAX_PLAYER_NAME);
	    format(string, sizeof(string), "*You give | %s Admin level %i!", tName, value);
	    SendClientMessage(playerid, COLOR_LIGHTBLUE, string); //Send to you
	    format(string, sizeof(string), "*You are set to %i level Admin | Admin: %s ", value, pName);
	    SendClientMessage(pID, COLOR_LIGHTBLUE, string); //Send to player
	    PlayerInfo[pID][pAdmin] = value;
	    format(string, sizeof(string), "*Head Admin %s | Maked Admin %s | Level: %i | ",pName,tName,value);
	    SendAdminMessage(COLOR_LIGHTBLUE, string); //Send to all admins :)
    }
    return 1;
}
Reply
#4

He's not looking for a SendMessageToAdmins function, he's looking for a function that sends the command information to the admins online.
Reply
#5

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
One alternative to this is:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(PInfo[playerid][Level] > 1)
    {
        SendCommandToAdmins(playerid, cmdtext);
    }
    return 0;
}

stock SendCommandToAdmins(playerid, command[])
{
    new string[], PLAYERSNAME[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PLAYERSNAME, MAX_PLAYER_NAME);
    format(string,sizeof(string),"Admin %s Has Used The Command: %s",PLAYERSNAME,command);
    SendMessageToAdmins(string);
    return 1;
}
Otherwise you can add it individually to all commands.
Like:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/testcommand", true) == 0) //Or ZCMD, DCMD, whatever...
    {
        SendCommandToAdmins(playerid, "testcommand");
        return 1;
    }
    return 0;
}
I use ZCMD.
Reply
#6

pawn Код:
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
    if(success == 1)
    {
        if(PInfo[playerid][Level] > 1)
        {
            SendCommandToAdmins(playerid, cmdtext);
        }
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)