Fast problem server got hacked fast fast fast
#10

More than one player version (spam might occur with more players with the same ip online, but none of them will be able to log into rcon).
pawn Code:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <foreach>

// MAIN:

main()
{
    print("Development Mode: rcon_protection_multiple.amx");
}

// CALLBACKS:

public OnGameModeInit()
{  
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    new playerid[3] = -1, count;
    foreach(new i: Player)
    {
        if(strcmp(ip, GetPlayerIP(i), true) == 0)
        {
            playerid[count] = i;
            count ++;

            if(count == 3) break;
        }
    }

    for(new i = 0; i < 3; i ++)
    {
        if(playerid[i] != -1)
        {
            if(success)
            {
                if(IsPlayerAdmin(playerid[i])) // Change this for your admin system's condition that validates a player's admin level possession.
                {
                    printf("[RCON] %s (%d) has logged-in.", PlayerName(playerid[i]), playerid[i]);
                }
                else
                {
                    printf("[RCON] %s (%d) was kicked from the server (Bad RCON Login).", PlayerName(playerid[i]), playerid[i]);
                    Kick(playerid[i]);
                }
            }
        }
    }
    return 1;
}

// FUNCTIONS:

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}

stock GetPlayerIP(playerid)
{
    new ip[16];
    GetPlayerIp(playerid, ip, sizeof(ip));
    return ip;
}
One player version (if two players with the same ip address are online, the first one will be kicked and the second one will log into rcon):
pawn Code:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <foreach>

// MAIN:

main()
{
    print("Development Mode: rcon_protection.amx");
}

// CALLBACKS:

public OnGameModeInit()
{  
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    new playerid = -1;
    foreach(new i: Player)
    {
        if(strcmp(ip, GetPlayerIP(i), true) == 0)
        {
            playerid = i;
            break;
        }
    }

    if(playerid != -1)
    {
        if(success)
        {
            if(IsPlayerAdmin(playerid)) // Change this for your admin system's condition that validates a player's admin level possession.
            {
                printf("[RCON] %s (%d) has logged-in.", PlayerName(playerid), playerid);
            }
            else
            {
                printf("[RCON] %s (%d) was kicked from the server (Bad RCON Login).", PlayerName(playerid), playerid);
                Kick(playerid);
            }
        }
    }
    return 1;
}

// FUNCTIONS:

stock PlayerName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    return name;
}

stock GetPlayerIP(playerid)
{
    new ip[16];
    GetPlayerIp(playerid, ip, sizeof(ip));
    return ip;
}
The rest is up to you, whether you allow more than one player with the same ip address connect to your server or not.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)