Admin In chat
#1

how to make it that when a admin chats it puts [ADMIN] NAME: HI WELCOME ETC
Reply
#2

You need to save your message into a string, then you just have to format a new string.

PHP код:
new string[64], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
format(stringsizeof(string),"Admin[%s]: %s",PlayerName,message);
SendMessageToAll(COLOR_ORANGE,string); 
Reply
#3

try this:
pawn Код:
forward AdminChat(color, message[])
declare this callback above.

pawn Код:
public AdminChat(color, message[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && IsPlayerAdmin(i))
        {
            SendClientMessage(i, color, message);
        }
    }
    return 1;
}
the actual callback. this would send the message to all admins online.

pawn Код:
command(achat, playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new message[128], string[128], playername[24];
        GetPlayerName(playerid, playername, sizeof(playername));
        if(sscanf(params, "S", message)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /achat [message]");
        format(string, sizeof(string), "[ADMIN] %s: %s", playername, message);
        AdminChat(0xFFFF00FF, string);
    }
    else SendClientMessage(playerid, 0xAAAAAAFF, "You're not an admin.");
    return 1;
}
the command, i used zcmd and sscanf for it. you can always use the default "OnPlayerCommandText" though.

hope this helps you, give me a reputation if it does, thanks!
Reply
#4

Quote:

CMD:a(playerid, params[]) {
return cmd_admin(playerid, params);
}

CMD:admin(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] >= 1) {
if(!isnull(params)) {

new
szMessage[128];

if(PlayerInfo[playerid][pAdmin] == 1) format(szMessage, sizeof(szMessage), "** {C85A17}Admin Level 1{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 2) format(szMessage, sizeof(szMessage), "** {FFFF00}Admin Level 2{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 3) format(szMessage, sizeof(szMessage), "** {99FF33}Admin Level 3{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 4) format(szMessage, sizeof(szMessage), "** {FF6633}Admin Level 4{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 1337) format(szMessage, sizeof(szMessage), "** {3366FF}Admin Level 5{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 133 format(szMessage, sizeof(szMessage), "** {FFFF00}Admin Level 6{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 9999) format(szMessage, sizeof(szMessage), "** {FF9933}Executive Admin{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 9999 format(szMessage, sizeof(szMessage), "** {FF0000}Admin Level 7{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 99999) format(szMessage, sizeof(szMessage), "** {FF0000}Admin Level 8{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 999995) format(szMessage, sizeof(szMessage), "** {FF00FF}Community Manager{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 99999 format(szMessage, sizeof(szMessage), "** {00FF00}Co-Community Owner{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else if(PlayerInfo[playerid][pAdmin] == 999999) format(szMessage, sizeof(szMessage), "** {00FF00}Community Owner{FFFFFF} %s says %s **", GetPlayerNameEx(playerid), params);
else format(szMessage, sizeof(szMessage), "* Undefined Admin (%i) %s: %s", PlayerInfo[playerid][pAdmin], GetPlayerNameEx(playerid), params);

SendAdminMessage(COLOR_WHITE, szMessage);
Log("logs/adminchat.log", szMessage);
}
else SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/a)dmin [admin chat]");
}
return 1;
}

Here Is the admin chat system I use, If it works fell free to change the Admin Ranks! But Im not sure If it will!

REP+
Reply
#5

Quote:
Originally Posted by MaximumGaming
Посмотреть сообщение
Here Is the admin chat system I use, If it works fell free to change the Admin Ranks! But Im not sure If it will!

REP+
i suggest using a stock for the admin ranks, such as:

pawn Код:
stock AdminRank(playerid)
{
    new string[32];
   
    switch(PlayerInfo[playerid][pAdmin])
    {
        case 1: // rank name
        case 2: // rank name
        // and so on...
    }
    return string;
}
and then

pawn Код:
format(string, sizeof(string), "%s %s: %s", AdminRank(playerid), PLAYERNAME, MESSAGE);
Reply
#6

Quote:
Originally Posted by MaximumGaming
Посмотреть сообщение
Here Is the admin chat system I use, If it works fell free to change the Admin Ranks! But Im not sure If it will!

REP+
Dont use this, this guy is using NGG's released script, and he proved himself to be a noob since he didn't even realise that SendClientMessageEx is one of the easiest ways to spot an ngg edit. It also doesn't help that you got all the same admin level names.
Reply
#7

I assume you're talking about the normal chat rather then a separate chat for admins.

pawn Код:
public OnPlayerText(playerid, text[]) // If you already have a OnPlayerText function in your script, just merge this into your current script.
{
    new string[128];
    if(IsPlayerAdmin(playerid)) // WARNING: this will check if the player is an RCON admin or not(which you properly already know, you've most likely got another way to check if a player is an admin or not, simply re-edit this line and you'll be fine.
    {
        format(string,sizeof(string),"[ADMIN] %s(%d): {FFFFFF}%s",GetName(playerid),playerid,text);
        SendClientMessage(playerid,GetPlayerColor(playerid),string);
    }
    else
    {
        format(string,sizeof(string),"%s(%d): {FFFFFF}%s",GetName(playerid),playerid,text);
        SendClientMessage(playerid,GetPlayerColor(playerid),string);
    }
    return 0; //return 0 so it doesn't output the normal chat line.
}
In addition you'll also need this GetName function, if you don't want to use this you could re-edit the code I've given above. You can put this snippet anywhere in your script as long as it's not in another function, once again you most likely know that.
pawn Код:
stock GetName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    return pName;
}
I haven't exactly tested this code yet, but if it doesn't work you've got a good idea on how you can go about creating such a thing. Hopefully I've understood your question; if not don't hesitate to ask.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)