29.05.2014, 12:18
How to make Admin Chat With '# chat'
variable -
help
variable -
PHP код:
PlayerInfo[playerid][pAdmin]
PlayerInfo[playerid][pAdmin]
public OnPlayerText(playerid, text[])
{
if(PlayerInfo[playerid][pAdmin] > 0 && text[0] == '#')
{
new message[128], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
format(message, sizeof(message), "Admin Chat: %s: %s", pName, text[1]);
for(new i = 0, i < MAX_PLAYERS, i++)
{
if(PlayerInfo[playerid][pAdmin] > 0 && IsPlayerConnected(i))
{
SendClientMessage(i, -1, text);
}
}
}
return 1;
}
public OnPlayerText(playerid, text[])
{
if(text[0] == '#' && PlayerInfo[playerid][pAdmin])
{
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "(ADMIN CHAT) %s: {FFFFFF}%s", name, text[1]);
//If you have a SendAdminMessage or something, use it here instead of the loop
for(new i = 0; i < MAX_PLAYERS; i++) //foreach is better :)
{
if(!IsPlayerConnected(i)) continue;
if(!PlayerInfo[playerid][pAdmin]) continue;
SendClientMessage(i, -1, str); //'-1' is the color, change that to whatever you want your admin chat to be
}
return 0;
}
return 1;
}
CMD:achat(playerid,params[]) { if(IsPlayerAdmin(playerid)) { new str[144]; if(sscanf(params,"s[144]",str)) { SendClientMessage(playerid,-1,"/achat [text]"); return 1; } else { new str1[128]; new name[128]; GetPlayerName(playerid,name,sizeof(name)); format(str1,sizeof(str1),"*Admin %s:%s",name,str); SendClientMessageToAll(-1,str1); } } else { SendClientMessage(playerid,-1,"You are not an Admin"); return 1; } return1; }