Jump to content

getcharip script command


Cookie

Recommended Posts


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  764
  • Reputation:   220
  • Joined:  11/14/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  69
  • Topics Per Day:  0.02
  • Content Count:  1315
  • Reputation:   372
  • Joined:  12/10/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   167
  • Joined:  11/10/11
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  67
  • Reputation:   75
  • Joined:  12/18/11
  • Last Seen:  

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

  • 3 months later...

  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Reviving this topic. It's a small patch and may be useful, so why not?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.00
  • Content Count:  213
  • Reputation:   109
  • Joined:  05/21/12
  • Last Seen:  

Agreed. I'll make a modification to one part of it and add it in after testing.

Implemented in r16957.

Link to comment
Share on other sites

×
×
  • Create New...