Advertisement
jlalt

phpesh

Jul 29th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.74 KB | None | 0 0
  1. //PHP
  2. <?php
  3.     set_time_limit(0);
  4.     ob_implicit_flush();
  5.  
  6.     $address = '127.0.0.1';
  7.     $port = 7778;
  8.  
  9.     $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
  10.     socket_connect($socket, $address, $port);
  11.  
  12.     $st = "1|Oma37"; // kind 1 - Get Player Money , Username = Oma37
  13.     socket_write($socket, $st, strlen($st));
  14.     $buffer = "";
  15.     socket_recv ($socket, $buffer, 2048, MSG_WAITALL);
  16.     echo "I've Got: ".$buffer;
  17.     socket_close($socket);
  18. ?>
  19.  
  20. //PWN
  21. #include <a_samp>
  22. #include <socket>
  23.  
  24. main() {}
  25.  
  26. new Socket:gSocket;
  27.  
  28. public OnGameModeInit() {
  29.  
  30.     gSocket = socket_create(TCP);
  31.     if(is_socket_valid(gSocket)) {
  32.  
  33.         socket_bind(gSocket, "127.0.0.1");
  34.         socket_listen(gSocket, 7778);
  35.     }
  36.     return 1;
  37. }
  38.  
  39. public OnGameModeExit() {
  40.  
  41.     if(is_socket_valid(gSocket))
  42.         socket_destroy(gSocket);
  43. }
  44.  
  45. public onSocketRemoteConnect(Socket:id, remote_client[], remote_clientid)
  46. {
  47.     printf("Incoming connection from [%d:%s]", remote_clientid, remote_client); // [id:ip]
  48.     return 1;
  49. }
  50.  
  51. public onSocketRemoteDisconnect(Socket:id, remote_clientid)
  52. {
  53.     printf("Remote client [%d] has disconnected.", remote_clientid); // [id:ip]
  54.     return 1;
  55. }
  56.  
  57. public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len)
  58. {
  59.     if(data[0] == '1') // Data KIND 1 - Get Player Money
  60.     {
  61.         new playername[MAX_PLAYER_NAME];
  62.         format(playername, sizeof playername, data[2]);
  63.         new varplayermoney[50]; // get player moneys inside this var
  64.         socket_sendto_remote_client(id, remote_clientid, varplayermoney); // send data back to php
  65.     }
  66.     printf("Remote client [%d] has sent: %s", remote_clientid, data); // id & data
  67.     return 1;
  68. }
  69.  
  70. public onSocketAnswer(Socket:id, data[], data_len)
  71. {
  72.     printf("onSocketAnswer(%i, %s, %i)", _:id, data, data_len);
  73.     return 1;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement