Script for IP Security
#1

I am looking for code that may limit the admin username to enter into it only one IP
Reply
#2

You Mean RCON?
Reply
#3

No. Admin Nickname

Example: Admin has joined to server (Only with IP: xxx.xxx.xxx.xxx)
If player Admin has joined to server with different IP (Server kick player)
Reply
#4

mhm .... i dont know the code from head but i can search
Reply
#5

And I find so ask
Reply
#6

Put this at the top of your gamemode:
pawn Code:
#define ADMIN_NAME "your_name"  // put your name instead of your_name
#define ADMIN_IP      "your_ip"       // put your IP instead of your_ip
And this in OnPlayerConnect callback:
pawn Code:
// OnPlayerConnect
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid,plname,sizeof(plname));
if(!strcmp(plname,ADMIN_NAME,true))
{
    new ip[32];
    GetPlayerIp(playerid,ip,sizeof(ip))
    if(strcmp(ip,ADMIN_IP,true))
    {
        SendClientMessage(playerid,-1,"This nickname is for admin only");
        Kick(playerid);
        return 1;
    }
}
Reply
#7

Norck has beaten me to it but I wrote something for you too which is easy to use.

You can add more names and IP's to this, just add more lines under:
pawn Code:
{"Join7", "127.0.0.1"}
If you add more, make sure you put a "," at the end of it except for the last one in the row.
Also, make sure you increase the value in #define ACCOUNTS_IN_SECURITY

pawn Code:
#include <a_samp>

enum info { name[24], ip[16] }

#define ACCOUNTS_IN_SECURITY 1

new IPSecurity[ACCOUNTS_IN_SECURITY][info] = {
    {"Join7", "127.0.0.1"}
};

public OnPlayerConnect(playerid) {

    new PlayerName[MAX_PLAYER_NAME], pIP[16], checkid = 999;

    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerIp(playerid, pIP, 16);
   
    for(new i = 0; i < ACCOUNTS_IN_SECURITY; i++) {
        if(!strcmp(IPSecurity[i][name], PlayerName, true)) { checkid = i; break; }
    }
   
    if(checkid != 999)
    {
        if(!strcmp(IPSecurity[checkid][ip], pIP, false)) {
            SendClientMessage(playerid, 0xFFFFFFAA, "Welcome back admin!");
        } else {
            SendClientMessage(playerid, 0xFFFFFFAA, "This is an admin account, your IP doesn't match the one that's listed inside the security system!");
            Kick(playerid);
        }
    }
}
Reply
#8

Thanks guys
Reply
#9

hmm what if IP is not static lol
it gonna kick him always when ever he joins after resetting modem :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)