12.11.2013, 13:42
Hello guys, I tried to make an admin chat but I failed, please help me with making one!
CMD:ac(playerid, params[]) { new string[128]; if(sscanf(params, "s[80]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ac [text]"); if(!pInfo[playerid][miniadmin]) return SendClientMessage(playerid, COLOR_GREY, "Admins only!"); new name[24]; GetPlayerName(playerid, name, sizeof(name)); format(string,sizeof(string), "Admin %s: %s",name,params); foreach(Player, i) { if(pInfo[i][miniadmin]) { SendClientMessage(i, COLOR_RED, string); } } return 1; }
CMD:a(playerid, params[])
{
if(*/ admin variable here */)
{
new text[124], string[124], pname[MAX_PLAYER_NAME];
if(sscanf(params, "s[124]", text)) return SendClientMessage(playerid, -1, "/a [text]");
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
format(string, sizeof(string),"%s: %s", pname, text);
SendAdminMessage(-1, string);
}
else return SendClientMessage(playerid, -1, "You're not an admin")
return 1;
}
SendAdminMessage(color, const string[])
{
foreach(Player, i)
{
if(*/ admin variable here */)
{
SendClientMessage(i, color, string);
}
}
return 1;
}
CMD:achat(playerid, params[])
{
new p2[128], Pna[32];
if(PlayerData [playerid] [ALevel] >= 1)
{
if( isnull (params)) return SendClientMessage(playerid, COLOR_RED, "/ac [msg]");
GetPlayerName(playerid, Pna, 32);
for(new i = 0; i<MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if(PlayerData[i] [ALevel] >= 1) // change ALevel to the one u store ur data
{
format(p2, 128, "Admin %s (%d): %s", Pna, playerid, params);
SendClientMessage(i , COLOR_KHAKI, p2); // change color_khaki to the color u want.
}
}
}
}
else
{
return 0;
}
return 1;
}
#Hello, what's up? !What's going on? @Heya
if(text[0] == '#') // You can change the character example to '!' or '@'
{
new string[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
strdel(text, 0, 1);
format(string, sizeof(string), "[ADMIN CHAT] %s [%d]: %s", pName, playerid, text);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerData[i][ALevel] > 0) // Player is connected and he's an admin
{
SendClientMessage(i, -1, string);
}
}
}
if(text[0] == '@' && AdminLevel[playerid] >= 1)
{
new name[24]; GetPlayerName(playerid,name,24);
format(string,256,"<Admin Chat> %s(%d): {AFAFAF}%s",name,playerid,text[1]);
MessageToAdmins(COLOR_WHITE,string);
return 0;
}
stock MessageToAdmins(color,const string[])
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) == 1)
{
if (AdminLevel[i] >= 1)
{
SendClientMessage(i, color, string);
}
}
}
return 1;
}