28.08.2015, 11:33
It should be
Also you missed to check if the given ip is even on the server or if more than one player has this ip (same house)
Simply because of the second case I wouldn't use this public at all and implement all necessary rcon commands into the admin system
Cleaned your code a bit
pawn Код:
if(strcmp(cheaterIp, ip, true) == 0)
Simply because of the second case I wouldn't use this public at all and implement all necessary rcon commands into the admin system
Cleaned your code a bit
PHP код:
SendAdminMessage(color, string[]) {
for(new i; i <= MAX_PLAYERS; ++i) {
if(PlayerInfo[i][pAdmin] > 0) {
SendClientMessage(i, color, string);
}
}
}
public OnRconLoginAttempt(ip[], password[], success) {
new
playerid = INVALID_PLAYER_ID,
tmp[128]
;
for(new i; i <= MAX_PLAYERS; ++i) {
if(GetPlayerIp(i, tmp, 16)) {
if(strcmp(ip, tmp, true) == 0) {
if(playerid != INVALID_PLAYER_ID) {
return false; // 2 players with this ip
}
playerid = i;
}
}
}
if(!GetPlayerName(playerid, tmp, MAX_PLAYER_NAME)) {
return false; // ip not playing in the server
}
if(!success) {
format(tmp, sizeof tmp, "** Warning: {FFFFFF}%s (%d) tried to RCON login with the password '%s' and fails.", tmp, playerid, password);
SendAdminMessage(COLOR_ACHAT, tmp);
} else {
if(PlayerInfo[playerid][pAdmin] > 0)) {
format(tmp, sizeof tmp, "** Admin %s (%d) has successfully RCON logged in.", tmp, playerid);
SendAdminMessage(COLOR_ACHAT, tmp);
} else {
format(tmp, sizeof tmp, "** %s has been automatically kicked from the server for RCON logging in not being an admin.", tmp);
SendClientMessageToAll(COLOR_ERROR, tmp);
DelayedKick(playerid);
}
}
return true;
}