How to use HTTP
#4

Emh.. its a bit hard than you think..


I mean:

Код:
        static void Main(string[] args)
        {
            string ip = null;

            // Here your code to get the IP

            if (ip != null)
            {
                // now the have the IP
                // send it

                Console.WriteLine("Your IP is: " + ip);

                WebClient wc = new WebClient();

                // i never used UploadString, but its just an example
             //   wc.UploadString("your_php_page", ip);

                // then you are ok.
            }
            else
            {
                Console.WriteLine("Unable to get your IP");
            }
        }
This should help you to understand the logic.

Then the PHP should save the string he get, anyway a SQLite code might be better since is better to manage than a plain text.


The PAWN script is a simple HTTP request to a page w/ the IP of the connected player as param something like this:

Код:
public OnPlayerConnect(playerid)
{
    new str [16 + 5];
    new IP [16];
    
    str = "d=";
    GetPlayerIp( playerid , ip , 16 );

    strcat(str, ip, 16+5);
       
    HTTP(playerid, HTTP_GET, "your_url", str, "OhWait");
    return true;
}

// remember to forward
public OhWait ( ... )
{
    if (response_code == 200 && strval(data) == 1)
    {
        GivePlayerMoney ( playerid , 50 );
    }
    else
    {
        // Here or the WEBSITE is down
        // Or the player is not connected using Your APP
    }
}
<b>Important</b>: to get this working, when the player is connected w/ the app, the php page should report a response with "1".
Reply


Messages In This Thread
How to use HTTP - by Olvaso42 - 31.07.2013, 11:47
Re: How to use HTTP - by ReVo_ - 31.07.2013, 12:42
Re: How to use HTTP - by Olvaso42 - 31.07.2013, 12:44
Re: How to use HTTP - by ReVo_ - 31.07.2013, 13:10
Re: How to use HTTP - by Olvaso42 - 31.07.2013, 13:31
Re: How to use HTTP - by Olvaso42 - 31.07.2013, 13:44
Re: How to use HTTP - by ReVo_ - 31.07.2013, 14:21
Re: How to use HTTP - by Olvaso42 - 31.07.2013, 14:29

Forum Jump:


Users browsing this thread: 1 Guest(s)