Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PWN
- public onSocketReceiveData(Socket:id, remote_clientid, data[], data_len) {
- if(data[0] == '1') { // IsPlayerConnected
- new pName[MAX_PLAYER_NAME], isConnected[10];
- format(isConnected, sizeof isConnected, "Offline");
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) {
- print("Called");
- if(!IsPlayerConnected(i)) continue;
- GetPlayerName(i, pName, sizeof pName);
- if(!strcmp(pName, data[2], false)) {
- format(isConnected, sizeof isConnected, "Online");
- break;
- }
- }
- socket_sendto_remote_client(id, remote_clientid, isConnected);
- }
- printf("Remote client [%d] has sent: %s", remote_clientid, data); // id & data
- return 1;
- }
- //The way I call the PHP script below
- function BuyVehicle(price, id)
- {
- $.ajax({
- type: 'POST',
- url: 'buy_action.php',
- data: 'vehicleModel=' + id + '&vehiclePrice=' + price,
- success: function(response) {
- if(response == '1') {
- playerDisconnected();
- }
- }
- });
- }
- //PHP
- <?php
- session_start();
- set_time_limit(0);
- ob_implicit_flush();
- $address = '127.0.0.1';
- $port = 7778;
- $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- socket_connect($socket, $address, $port);
- $st = "1|".$_SESSION["sessionUsername"]."";
- socket_write($socket, $st, strlen($st));
- $buffer = "";
- socket_recv($socket, $buffer, 2048, MSG_WAITALL);
- if(strcmp($buffer, "Online") != 0) {
- echo '1';
- }
- socket_close($socket);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement