18.03.2017, 06:55
(
Последний раз редактировалось Mic_H; 18.03.2017 в 08:58.
)
PHP код:
#define MAX_ADMINLVL 8
new AdminRanks[MAX_ADMINLVL][13] = {
"Player",
"Trial Admin",
"Basic Admin",
"Senior Admin",
"Anon",
"Head Admin",
"Anon",
"Owner"
};
stock ServerStatus(playerid)
{
new status[15] = "Player";
if(pInfo[playerid][Adminlevel] > 0 && pInfo[playerid][Adminlevel] < MAX_ADMINLVL)
{
status = AdminRanks[pInfo[playerid][Adminlevel]]; //Admin -> First Priority
}
else if(pInfo[playerid][Adminlevel] >= MAX_ADMINLVL) //Edited '>' -> '>='
{
status = "Pro-Owner";
}
else if(pInfo[playerid][VIPlevel] > 0) // VIP -> Second
{
status = "VIP";
}
return status;
}
CMD:g2(playerid, params[])
{
new string[256], text[100];
if(sscanf(params, "s[100]", text)) return SendClientMessage(playerid, -1, "{6a696a}[cmd]: /g(lobalchat) {9c9a9c}[msg]");
format(string, sizeof(string), "{A9C4E4}[Global Chat] {EAEAEA}%s %s: %s", ServerStatus(playerid), GetName(playerid), text);
//foreach(Player, i)
for(new i = 0; i <= GetPlayerPoolSize(); i++) //Edited '<=', else the last guy won't get the message :P
{
if(IsPlayerConnected(i))
{
SendClientMessage(i, COLOR_SERVER, string);
}
}
/*
Mistakes:>
1. You were sending to ALL players.... So 10 players IG = 10 messages..
2. You were using Ifs, not if-else if.. = Messages have a chance of being sent 3-4Times i.e., if a player is a VIP, Admin.
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][VIPlevel] == 0)
{
format(string, sizeof string, "%s: %s", GetName(playerid), text);
}
if(pInfo[i][VIPlevel] == 1)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}VIP %s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 1)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Trial Admin%s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 2)
{
format(string, sizeof string, "{}[Global Chat] {EAEAEA}Basic Admin %s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 3)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Senior Admin %s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 4)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Anon: %s", text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 5)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Head Admin %s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 6)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Anon: %s", text);
SendClientMessageToAll(COLOR_SERVER, string);
}
if(pInfo[i][Adminlevel] == 7)
{
format(string, sizeof string, "{A9C4E4}[Global Chat] {EAEAEA}Owner %s: %s", GetName(playerid), text);
SendClientMessageToAll(COLOR_SERVER, string);
}
}
}*/
return 1;
}