Exemplo n.º 1
0
 /**
  * Handle the event.
  *
  * @param  ProductWasPurchased  $event
  * @return void
  */
 public function handle(ProductWasPurchased $event)
 {
     //
     if ($event->oreder->status != 2) {
         $product = Product::where('id', $event->oreder->product_id)->first();
         $server = Server::where('id', $product->server_id)->first();
         $command = str_replace(':steam_id', $event->oreder->steam_id, $product->command);
         $command = str_replace(':quantity', $event->oreder->quantity, $command);
         $data = new SourceQuery();
         try {
             $data->Connect($server->ip, $server->port, 3, $server->engine);
             $data->SetRconPassword($server->rcon_password);
             $data->Rcon($command);
             $event->oreder->status = 2;
             $event->oreder->completed_at = Carbon::now();
             $event->oreder->save();
         } catch (\Exception $e) {
             $e->getMessage();
         }
     }
 }
Exemplo n.º 2
0
<?php

require __DIR__ . '/../SourceQuery/bootstrap.php';
use xPaw\SourceQuery\SourceQuery;
// For the sake of this example
Header('Content-Type: text/plain');
Header('X-Content-Type-Options: nosniff');
// Edit this ->
define('SQ_SERVER_ADDR', 'localhost');
define('SQ_SERVER_PORT', 27015);
define('SQ_TIMEOUT', 1);
define('SQ_ENGINE', SourceQuery::SOURCE);
// Edit this <-
$Query = new SourceQuery();
try {
    $Query->Connect(SQ_SERVER_ADDR, SQ_SERVER_PORT, SQ_TIMEOUT, SQ_ENGINE);
    $Query->SetRconPassword('my_awesome_password');
    var_dump($Query->Rcon('say hello'));
} catch (Exception $e) {
    echo $e->getMessage();
} finally {
    $Query->Disconnect();
}