Cookie Posted August 17, 2012 Posted August 17, 2012 (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 August 23, 2012 by Maki Added functionality for char/AID ID.
Ind Posted August 18, 2012 Posted August 18, 2012 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?
Kenpachi Posted August 18, 2012 Posted August 18, 2012 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...
Arcenciel Posted August 18, 2012 Posted August 18, 2012 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?
Cookie Posted August 18, 2012 Author Posted August 18, 2012 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.
Ind Posted August 18, 2012 Posted August 18, 2012 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)
Cookie Posted August 18, 2012 Author Posted August 18, 2012 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
Panallox Posted August 19, 2012 Posted August 19, 2012 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. 1
Trojal Posted August 22, 2012 Posted August 22, 2012 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).
Euphy Posted November 24, 2012 Posted November 24, 2012 Reviving this topic. It's a small patch and may be useful, so why not?
Cookie Posted November 24, 2012 Author Posted November 24, 2012 Agreed. I'll make a modification to one part of it and add it in after testing. Implemented in r16957.
Recommended Posts