You want this:
If a player is connected w/ your program he will get 500 money, else no. Ok, if you want to use HTTP function you can do something like this: (Two ways) 1. When the player open the application, get his IP and send the IP to a PHP page and save it. When a player w/ the same IP connect to the server, give him the moneys and remove the IP from the list. 2. In the application add a "nickname" box, send it to the server. Same above, just with the nickname. |
forward MyHttpResponse(index, response_code, data[]); public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp("/hello",cmdtext,true)) { HTTP(playerid, HTTP_GET, "kc.gd/hello.txt", "", "MyHttpResponse"); return 1; } return 0; } public MyHttpResponse(index, response_code, data[]) { // In this callback "index" would normally be called "playerid" ( if you didn't get it already :) ) new buffer[ 128 ]; if(response_code == 200) //Did the request succeed? { //Yes! format(buffer, sizeof(buffer), "The URL replied: %s", data); SendClientMessage(index, 0xFFFFFFFF, buffer); } else { //No! format(buffer, sizeof(buffer), "The request failed! The response code was: %d", response_code); SendClientMessage(index, 0xFFFFFFFF, buffer); } }
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"); } }
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 } }
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"); } } 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 } } |
static void Main (string [] args) { string ip = null; 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"); } }
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub End Class
static void Main(string[] args) { string ip = null; 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 // then you are ok. } else { Console.WriteLine("Unable to get your IP"); } }