Jump to content
Cookie

getcharip script command

Recommended Posts

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.
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Maybe I'm too sleepy, but why do we need such a command? You can simply do a SQL query to get a characters IP...

Link to comment
Share on other sites

Maybe I'm too sleepy, but why do we need such a command? You can simply do a SQL query to get a characters IP...

Makes it easier for scripting?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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).

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.