RCON Login warning system, what is wrong here?
#1

Код:
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
Reply
#2

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(colorstring[]) {
    for(new 
i<= MAX_PLAYERS; ++i) {
        if(
PlayerInfo[i][pAdmin] > 0) {
            
SendClientMessage(icolorstring);
        }
    }
}
public 
OnRconLoginAttempt(ip[], password[], success) {
    new
        
playerid INVALID_PLAYER_ID,
        
tmp[128]
    ;
    for(new 
i<= MAX_PLAYERS; ++i) {
        if(
GetPlayerIp(itmp16)) {
            if(
strcmp(iptmptrue) == 0) {
                if(
playerid != INVALID_PLAYER_ID) {
                    return 
false// 2 players with this ip
                
}
                
playerid i;
            }
        }
    }
    if(!
GetPlayerName(playeridtmpMAX_PLAYER_NAME)) {
        return 
false// ip not playing in the server
    
}
    if(!
success) {
        
format(tmpsizeof tmp"** Warning: {FFFFFF}%s (%d) tried to RCON login with the password '%s' and fails."tmpplayeridpassword);
        
SendAdminMessage(COLOR_ACHATtmp);
    } else {
        if(
PlayerInfo[playerid][pAdmin] > 0)) {
            
format(tmpsizeof tmp"** Admin %s (%d) has successfully RCON logged in."tmpplayerid);
            
SendAdminMessage(COLOR_ACHATtmp);
        } else {
            
format(tmpsizeof tmp"** %s has been automatically kicked from the server for RCON logging in not being an admin."tmp);
            
SendClientMessageToAll(COLOR_ERRORtmp);
            
DelayedKick(playerid);
        }
    }    
    return 
true;

Reply
#3

I managed to fix before you answered but you came up with more useful stuff, thanks man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)