20.03.2012, 00:08
how to make it that when a admin chats it puts [ADMIN] NAME: HI WELCOME ETC
new string[64], PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
format(string, sizeof(string),"Admin[%s]: %s",PlayerName,message);
SendMessageToAll(COLOR_ORANGE,string);
forward AdminChat(color, message[])
public AdminChat(color, message[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && IsPlayerAdmin(i))
{
SendClientMessage(i, color, message);
}
}
return 1;
}
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;
}
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+ |
stock AdminRank(playerid)
{
new string[32];
switch(PlayerInfo[playerid][pAdmin])
{
case 1: // rank name
case 2: // rank name
// and so on...
}
return string;
}
format(string, sizeof(string), "%s %s: %s", AdminRank(playerid), PLAYERNAME, MESSAGE);
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.
}
stock GetName(playerid)
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
return pName;
}