[Tutorial] How to detect an IP, and make the account admin.
#1

NOTE: Do not use this at a network with multiple people playing samp.

So, I've seen allot of people having trouble with this, so i thought lets make my first tutorial ^^. It's small and simple!

pawn Код:
if(PlayerInfo[playerid][pAdmin] <= 0) // pAdmin = the admin variable, detects if the player already is admin.
{
    new root[16]; // Creating the root variable
    GetPlayerIp(playerid, root, sizeof(root)); // Here it gets the player his ip, and stores it as "root"
    if(!strcmp(root, "127.0.0.1")) // Here it compares the player IP with the IP: 127.0.0.1(localhost), and if it is correct, it redirects, if not, it skips.
    {
        PlayerInfo[playerid][pAdmin] = 6; // Here it will set the admin level of the player.
        SendClientMessage(playerid, -1, "Hi there server owner, your admin level has been set to 6!"); // and now we send the player a message.
    }
}
This can be placed wherever you feel like, under a command maybe? I would reccomend to place it at OnPlayerConnect.
Reply
#2

What if the so called "Admin" has a dynamic IP ?!
Reply
#3

Quote:
Originally Posted by Beaner
Посмотреть сообщение
What if the so called "Admin" has a dynamic IP ?!
127.0.0.1 is the local host and never changes.
Reply
#4

Quote:
Originally Posted by Beaner
Посмотреть сообщение
What if the so called "Admin" has a dynamic IP ?!
Then you should use a free DNS solution such as NO-IP, which will resolve your IP as an CNAME, then use NO-IP DUC to keep your IP updated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)