Code: Select all
CMD:a(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid,0xFF0000AA, !"Вы не администратор!");
if(isnull(params))
return SendClientMessage(playerid,0xFF8000AA, !"Используйте: /a [сообщение]");
if(strlen(params[0]) >= 110)
return SendClientMessage(playerid,0xFF8000AA, !"Макс. длина сообщения - 110 символов");
new mes[139 + 1];
format(mes,sizeof(mes),"[A]%s[%d]:%s",PlayerName,playerid,params[0]);
AdminMessage(0xFF8000AA,mes,1);
return 1;
}
stock AdminMessage(color,const string[],level)
{
#if defined foreach
foreach(new i : Admins)
#else
for(new i = GetPlayerPoolSize(); i != -1; --i)
if(IsPlayerConnected(i))
#endif
if(PlayerInfo[i][pAdmin] >= level) SendClientMessage(i, color, string);
return true;
}
Если есть foreach
- Spoiler
- Ко всем глобальным переменным.
Code: Select all
new Iterator:Admins<MAX_PLAYERS>;
В public OnPlayerConnect(playerid)Code: Select all
if(PlayerInfo[playerid][pAdmin] >= 1) Iter_Add(Admins,playerid);
В public OnPlayerDisconnect(playerid, reason)Code: Select all
if(PlayerInfo[playerid][pAdmin] >= 1) Iter_Remove(Admins,playerid);