How do I create a Random IP generater for Hacking Game

Get help using Construct 2

Post » Sun Oct 23, 2016 1:38 pm

When someone register's to my Game using register, I want them to have a Random fake IP

When they register
They will go to the homepage and it will say
Welcome,User | IP: 0.19.192.12 <--- random

It's a bitcoin hacking game

Sorry if I dident explain properly
B
6
Posts: 23
Reputation: 304

Post » Sun Oct 23, 2016 1:50 pm

You can generate 4 random numbers and store them in variables then combine them and store them in a string.

Random_IP = <Random nr 1> & "." & <Random nr 2> & "." & <Random nr 3> & "."& <Random nr 4>

You can then use tokenat(Text, index, Seperator) if you ever have to extract the numbers again.

Tokenat (Random_IP, 0, ".") <---- Will get you <Random nr 1> in above. So you simply increase the index number to get the rest of the numbers.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Sun Oct 23, 2016 2:00 pm

If it doesn't have to be unique or saved, you could just do something like:

Set Text "Welcome, User | IP: " & floor(random(256)) & "." & floor(random(256)) & "." & floor(random(256)) & "." & floor(random(256))
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
33
S
9
G
7
Posts: 450
Reputation: 6,780

Post » Sun Oct 23, 2016 6:00 pm

Thanks guys really appreciate your help! <3
B
6
Posts: 23
Reputation: 304

Post » Sun Oct 23, 2016 6:22 pm

why do you want to use a fake ip if you can use the real one?

is simple very simple in php:

Code: Select all
echo $_SERVER['REMOTE_ADDR'];


or

Code: Select all
function getUserIP()
{
    $client  = @$_SERVER['HTTP_CLIENT_IP'];
    $forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
    $remote  = $_SERVER['REMOTE_ADDR'];

    if(filter_var($client, FILTER_VALIDATE_IP))
    {
        $ip = $client;
    }
    elseif(filter_var($forward, FILTER_VALIDATE_IP))
    {
        $ip = $forward;
    }
    else
    {
        $ip = $remote;
    }

    return $ip;
}


$user_ip = getUserIP();

echo $user_ip;


you have just to use ajax
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Sun Oct 23, 2016 7:07 pm

#Ribis thanks for the Help tho but
I don't want players real IP to be found by others
This is a Bitcoin hacking game where each players will have a Virtual fake IP associated with their account, so they can hack each others IP address and steal Bitcoins from others and be the richest upgrading their security by spending the stolen bitcoins and make it harder for other to hack their IP
B
6
Posts: 23
Reputation: 304


Return to How do I....?

Who is online

Users browsing this forum: amazingdream, lordsas, mekonbekon and 49 guests