On that part, i will specify better:
Tag can be anything that you want to it be. 'But exactly what?' You can ask me. Well, all Ajax actions must be very well setup or any mistake, you can mess up all your online data. So, be very careful when naming it!
In our case, it will be 'pegaip' (explained early why of that name and what it means in english) and it will identify what we are wanting to get from our database.
With that explained, lets go on explain what URL is for this.
The URL will contain your website database file path. Where say "(...)/pegaip.php" is the PHP file that we will get the necessary stuff to get players IP. The PHP file can named as you want, BUT, put the EXACT PHP file name or you will get error!
So, in our case, will be "http://polargames.com.br/pegaip.php".
With that done, lets go for the next event:
- Create an Ajax On Completed event ( remember the tag mentionated before? you will put it's name here too!) put the tag name we created before.
- Create a Text Set Text action where in Text, you put Ajax.LastData. WAIT! Why put that, right? It's because you always works with the Last Data Ajax was using (it don't save all data it work with, just the last one).
Note: You can create another action, like Ajax one, but, how the purpose of this tutorial is to be simple and show how to get IP from players, will be like that.
With that said/wrote, let's continue:
To get players IP, your C2 game is complete, BUT, only by the game itself, you won't be able to get the IPs! For that, you will have to use a PHP file! PHP do that work for you! ;]
For that:
Create a PHP file with your favorite notepad program with code show on image, that is:
<?php
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
$ip´= $_SERVER['REMOTE_ADDR'];
echo $ip;
?>
Thats it! I don't know that much about PHP, just the basic of the basic, so, i can't tell how exactly this code works. But, if someone, in comments, explain how it works, i'll put here with the right credits! But also have some youtube tutorials that explain how PHP works, so, you can search there also! =]
By the way, this tutorial was only possible thanks to a friend that showed me how to do this and his name is Willian Zarpellon! THANKS A LOT, DUDE!
I hope you all enjoy this tutorial and make nice games! =]