View Single Post
  #5  
Old 08-28-2014, 12:32 AM
Restraint Restraint is offline
NaS
Join Date: Jan 2014
Posts: 21
Restraint will become famous soon enough
It's possible already, but a pain in the ass. On UN, I made it so players get clientr.ip set to their IP when they log on.

How do you retrieve their IP?

First, you have to give your NPC server:

r accounts/*/*

DON'T give it rw, or else I might log onto your server and give myself a full RC.

Once you've done that, you get the filepath to the player's file. For example -

For my account (Restraint), my account file would be in the following location:

accounts/Re/Restraint.txt

And if you .loadlines() it, you will find a line listed as "IP x.x.x.x" -- I *think*it's near the bottom (under comments but above rights, if I recall).

If it's near the bottom, you loop from the end towards the beginning and break; when you reach it.

If it's near the top, you loop from the beginning to the end and break; when you reach it.

There are some "special" cases with the accounts/ folder, though.

An account like "(npcserver)" would not go under:

accounts/(n/(npcserver).txt

It goes under:

accounts/special/%00npcserver%00.txt

(where %00's are the 'escaped' versions of ( and ) )

So basically you do SOMETHING LIKE the following:

PHP Code:
const template "accounts/%s/%s.txt";
public function 
getIP(acc) {
 
temp.escape acc.escape(); // Or whatever. Is this the SQL one? Whatever it is.
 
temp.folder escape.substring(02);
 if (
folder.contains("%")) { // Could also do .pos()
  
folder "special";
 }
 
 
temp.directory format(templatefolderescape);
 
temp.lines.loadLines(directory);

 for (
temp.linelines) { // If it's near top, loop from top
  
if (line.starts("IP")) {
   
temp.ip line.substring(2).trim(); // .trim() because I think it has garbage spaces
   
break;
  }
 }

 return(
ip);

Or something. That's really just a guess mostly, but you should be able to figure it out from there.
__________________
Hi. I'm NaS!
Reply With Quote