[Tutorial] How to detect an IP, and make the account admin. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (
https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to detect an IP, and make the account admin. (
/showthread.php?tid=474015)
How to detect an IP, and make the account admin. -
ThaCrypte - 05.11.2013
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.
Re: How to detect an IP, and make the account admin. -
Beaner - 06.11.2013
What if the so called "Admin" has a dynamic IP ?!
Re: How to detect an IP, and make the account admin. -
Wizzy951 - 06.11.2013
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.
Re: How to detect an IP, and make the account admin. -
Khanz - 06.11.2013
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.