OnRconLoginAttempt

From SA-MP Wiki

Jump to: navigation, search

OnRconLoginAttempt


Warning: This is a new callback working since SA-MP 0.3. It won't work in previous versions.


This callback is called when someone tries to login to RCON, succesful or not.


Parameters:
(ip[], password[], success)
ip[]The IP of the player who tried to login to RCON.
password[]The password they tried to login with.
success0 if the password was incorrect. 1 if the password was correct.


Note: This callback works only for in-game RCON, if you want to disable the remote RCON, add rcon 0 to the server.cfg


Example:

public OnRconLoginAttempt(ip[], password[], success)
{
    if(!success) //If the password was incorrect
    {
        new pip[16];
        for(new i=0; i<MAX_PLAYERS; i++) //Loop through all players
        {
            GetPlayerIp(i, pip, sizeof(pip));
            if(!strcmp(ip, pip, true)) //If a player's IP is the IP that failed the login
            {
                SendClientMessage(i, 0xFFFFFFFF, "Wrong Password. Bye!"); //Send a message
                Ban(i); //They are now banned.
                printf("FAILED RCON LOGIN BY IP %s USING PASSWORD %s",ip, password);
            }
        }
    }
    return 1;
}

Related Functions

The following functions might be useful, as they're related to this callback in one way or another.