RCON Login warning system, what is wrong here? -
hydravink - 27.08.2015
Код:
public OnRconLoginAttempt(ip[], password[], success)
{
new cheaterName[MAX_PLAYER_NAME],
cheaterIp[64],
string[512];
for(new j=0; j<=MAX_PLAYERS; j++)
{
if(IsPlayerConnected(j))
{
GetPlayerIp(j, cheaterIp, sizeof(cheaterIp));
if(strcmp(cheaterIp, ip, true))
{
GetPlayerName(j, cheaterName, sizeof(cheaterName));
}
}
}
if(!success)
{
for(new i=0; i<=MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 0)
{
format(string, sizeof(string), "** Warning: {FFFFFF}%s (%d) tried to RCON login with the password '%s' and fails.", cheaterName, GetPlayerIdFromName(cheaterName), password);
SendClientMessage(i, COLOR_ACHAT, string);
}
}
}
}else if(success && (PlayerInfo[GetPlayerIdFromName(cheaterName)][pAdmin] > 0))
{
for(new i=0; i<=MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 0)
{
format(string, sizeof(string), "** Admin %s (%d) has successfully RCON logged in.", cheaterName, GetPlayerIdFromName(cheaterName));
SendClientMessage(i, COLOR_ACHAT, string);
}
}
}
}else if(success && (PlayerInfo[GetPlayerIdFromName(cheaterName)][pAdmin] == 0))
{
format(string, sizeof(string), "** %s has been automatically kicked from the server for RCON logging in not being an admin.", cheaterName);
SendClientMessageToAll(COLOR_ERROR, string);
DelayedKick(GetPlayerIdFromName(cheaterName));
}
return 1;
}
This works but not correctly. Basically ids are switched... If I log in (I am an admin), it kicks a player from the server because he wasn't admin and he logged in... When someone who isn't admin tries to login and fails it says somebody other is doing it... Very bugged, please help.... Thanks
P.S. I have no idea what I did wrong here xD
AW: RCON Login warning system, what is wrong here? -
Nero_3D - 28.08.2015
It should be
pawn Код:
if(strcmp(cheaterIp, ip, true) == 0)
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
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;
}
Re: RCON Login warning system, what is wrong here? -
hydravink - 28.08.2015
I managed to fix before you answered but you came up with more useful stuff, thanks man