C:\Users\Marius\Desktop\GM\gamemodes\GM.pwn(448) : warning 217: loose indentation C:\Users\Marius\Desktop\GM\gamemodes\GM.pwn(463) : error 030: compound statement not closed at the end of file (started at line 400) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error.
CMD:admins(playerid, params[]) { new sendername[MAX_PLAYER_NAME], string[128]; if(IsPlayerConnected(playerid)) { SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Player[i][pAdmin] == 1338) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1337) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Manager: {A31818}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 5) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 4) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 3) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 2) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername); } else { if(!IsPlayerConnected(i)) { format(string, sizeof(string), "{08FC9A}There are no admins online."); SCM(pid, -1, string); } return 1; } } }
CMD:admins(playerid, params[]) { new sendername[MAX_PLAYER_NAME], string[128]; if(IsPlayerConnected(playerid)) { SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Player[i][pAdmin] == 1338) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1337) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Manager: {A31818}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 5) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 4) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 3) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 2) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername); } else { if(!IsPlayerConnected(i)) { format(string, sizeof(string), "{08FC9A}There are no admins online."); SCM(pid, -1, string); } return 1; } } }
Код:
CMD:admins(playerid, params[]) { new sendername[MAX_PLAYER_NAME], string[128]; if(IsPlayerConnected(playerid)) { SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Player[i][pAdmin] == 1338) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1337) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Manager: {A31818}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 5) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 4) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 3) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 2) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername); } else { if(!IsPlayerConnected(i)) { format(string, sizeof(string), "{08FC9A}There are no admins online."); SCM(pid, -1, string); } return 1; } } } |
CMD:admins(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[128];
SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Player[i][pAdmin] == 1338)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 1337)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Server Manager: {A31818}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 5)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 4)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 3)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 2)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername);
SCM(pid, COLOR_WHITE, string);
}
if(Player[i][pAdmin] == 1)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername);
}
}
else
{
if(!IsPlayerConnected(i))
{
format(string, sizeof(string), "{08FC9A}There are no admins online.");
SCM(pid, -1, string);
}
}
}
return 1;
}
CMD:admins(playerid, params[]) { new sendername[MAX_PLAYER_NAME], string[128]; if(IsPlayerConnected(playerid)) { SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins"); for(new i = 0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(Player[i][pAdmin] == 1338) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1337) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Manager: {A31818}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 5) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 4) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 3) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 2) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername); SCM(pid, COLOR_WHITE, string); } if(Player[i][pAdmin] == 1) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername); } else { if(!IsPlayerConnected(i)) { format(string, sizeof(string), "{08FC9A}There are no admins online."); SCM(pid, -1, string); } return 1; } } } } }
PHP код:
|
CMD:admins(playerid, params[])
{
new sendername[MAX_PLAYER_NAME], string[128], count;
SCM(pid, -1, "{FF6600}Online {FFFFFF}Admins");
for (new i = 0, j = GetPlayerPoolSize(); i <= j; i++) // foreach(new i : Player)
{
if (!IsPlayerConnected(i)) continue;
GetPlayerName(i, sendername, sizeof(sendername));
switch (Player[i][pAdmin])
{
case 1338: format(string, sizeof(string), "Server Founder: {FF0000}%s", sendername);
case 1337: format(string, sizeof(string), "Server Manager: {A31818}%s", sendername);
case 5: format(string, sizeof(string), "Server Mapper: {0080FF}%s", sendername);
case 4: format(string, sizeof(string), "Leader Coordinator: {6633CC}%s", sendername);
case 3: format(string, sizeof(string), "Server Guardian: {A173FF}%s", sendername);
case 2: format(string, sizeof(string), "Server Moderator: {5CFEADFF}%s", sendername);
case 1: format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername);
}
SCM(pid, -1, string);
count++;
}
if (!count) SCM(pid, -1, "{08FC9A}There are no admins online.");
return 1;
}
Let's optimize it, shall we?
- foreach is recommended for player loops, if you don't want to use it then use atleast GetPlayerPoolSize. - switch is faster than many if statements - in order to send a message that no admins are online the loop MUST finish first. - NEVER use return in loops unless you want to stop them PHP код:
|
The "there are no admins online" message is not shown
has the loop not finished? also where could I put the message: "There are currently %d admins online" |
... case 1: format(string, sizeof(string), "Trial Admin: {94FEC9FF}%s", sendername); default: continue;
if (!count) SCM(pid, -1, "{08FC9A}There are no admins online.");
else
{
format(string, sizeof(string), "There are currently %d admins online", count);
SCM(pid, -1, string);
}
if(Player[i][pAdmin] == 1337) { GetPlayerName(i, sendername, sizeof(sendername)); format(string, sizeof(string), "Server Manager: {A31818}%s", sendername); SCM(pid, COLOR_WHITE, string); count++ }