• Having trouble receiving email verification when signing up? Contact a staff member via our Discord server!
  • Consider joining our Discord server if you haven't already! Discord is a free voice and text chat platform that's more or less a combination of Skype and Teamspeak. Using Discord, you can chat with other Relic Castle members in real-time! Wowza! Click here for the details!
Geolocating the Player

Geolocating the Player

Pokémon Essentials Version
v16.2 ➖
What's this?
This is a simple script that downloads information from an API to geolocate the player, since the one included in Pokémon Essentials died sometime ago.

Place in a section above Main in your Script Editor:
def getLocation
  # See http://ip-api.com/docs/api:returned_values#selectable_output
  # for other returned values
  if formatted[0]=="success"
	Kernel.pbMessage(_INTL("You came from {1}, {2}.",formatted[2],formatted[1]))
Use 'getLocation' in a script call.

Design Notes
As far as I'm aware, only Vivillion forms need to rely on this, but you can be creative with it!

Instead of using it in a text message, you could also store the values for future use, all inside the script. The values are stored into an array, that will look something like:
Where "status" will be either "success" or "fail", if the API failed to retrieve the information. The script will not print the information in a message unless the API returns "status" as "success". You should also be doing that all times, and stop storing the remaining (faulty or non-existant) information.

That said, you can store 'formatted[x]' at will instead of printing it into a text message. Where X is 1 for Country, 2 for City, 0 for Status. See the API's Documentation for other possible fields it can return.

Please give credit if used to:

Mr. Gela

Please do not redistribute this anywhere resource anywhere else. If you wish to share this, link to this site.

Por favor da créditos si lo utilizas a:
Mr. Gela

Por favor no redistribuyas este recurso en ningún otro lugar. Si quieres compartir esto, utiliza un enlace a este sitio.
Likes: Radical Raptr
Mr. Gela
First release
Last update
0.00 star(s) 0 ratings

More resources from Mr. Gela