Jump to content

Recommended Posts

Posted (edited)

Attached is the differential.

Basically can be used to get the IP of the currently attached player or character name/account ID/char ID specified.

Example:

@ip$ = getcharip;

OR.

@ip$ = getcharip("[GM] Cookie");

OR.

@aid = 2000000;

getcharip(@aid);

... You get the point.

If character isn't attached, returns a blank str.

Post your opinions. I really don't mind either way if it's added or not. I just thought I'd share. :) If it's ok, I'll add it to the SVN.

Cookie getcharip.patch

Edited by Maki
Added functionality for char/AID ID.
Posted

as for the patch just something I think would be changeworthy,

in

	if ( (sd = map_nick2sd(script_getstr(st, 2))) != NULL )

it runs a nick check without checking if the argument is a str, i'd say a script_isstring would be of good use there.


the code aside, where do you think this would come in to be useful?

Posted

I originally query_sql for the last IP in a script function I made. Just seemed ridiculous. So, I made this. That's all.

Thought I would share, however. If anything, it can be a custom download or what-not.

Posted

I originally query_sql for the last IP in a script function I made. Just seemed ridiculous. So, I made this. That's all.

Thought I would share, however. If anything, it can be a custom download or what-not.

either way I'm asking because I couldn't think of a place the player ip would be needed script side (whether its a query or this function)

Posted

I originally query_sql for the last IP in a script function I made. Just seemed ridiculous. So, I made this. That's all.

Thought I would share, however. If anything, it can be a custom download or what-not.

either way I'm asking because I couldn't think of a place the player ip would be needed script side (whether its a query or this function)

Oh, maybe it's just me then. I use it all the time for custom events, tracking, et cetera. XD

Posted

Recommended for a public download, it's useful for retrieving the IP address without the need of an SQL table look-up (given a lot of servers probably run on MyISAM tables, SQL table look-ups would probably be extremely resource intensive), however it's probably not relevant enough to commit as an official script command though.

Nice command though.

  • Upvote 1
Posted

For a machine, the 4 byte ip address as an integer is [always?] more useful than the dotted quad string representation... since you can easily apply masks to the bytes which are used [all the time] to search similar IPs or IP spaces. MySQL has a function to convert from integer to dotted quad if you need it, too.

Also, strings take up so many more bytes and their internals are just ugly in C.

I'm saying this because I see ip2str (which I assume converts the integer to a dotted quad representation, but I didn't really look it up).

  • 3 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...