Ejemplo n.º 1
0
 /**
  * Logs action to database
  *
  * @param string|Player $target
  * @param string        $command
  * @param string        $message
  * @param int           $duration
  * @param bool|true     $sys
  *
  * @return \BFACP\Adkats\Record
  */
 private function log($target, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     $command = Command::where('command_key', $command)->first();
     if (!$command) {
         throw new RconException(500, 'Invalid command type');
     }
     if (!$target instanceof Player && is_string($target) && !in_array($command->command_key, ['server_nuke'])) {
         $target = Player::where('GameID', $this->gameID)->where('SoldierName', $target)->first();
     }
     if ($target instanceof Player) {
         $target_name = $target->SoldierName;
         $target_id = $target->PlayerID;
     } else {
         $target_name = is_null($target) ? 'Server' : $target;
         $target_id = null;
     }
     if ($this->admin instanceof Player) {
         $source_name = $this->admin->SoldierName;
         $source_id = $this->admin->PlayerID;
     } else {
         $source_name = $this->user->username;
         $source_id = null;
     }
     $data = [];
     if ($command->command_key == 'admin_say') {
         $data['chat'] = Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => $source_id, 'logSoldierName' => $source_name, 'logSubset' => 'Global']);
         if ($this->admin instanceof Player) {
             $data['chat']['player'] = $this->admin;
         }
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = $source_name;
     $record->source_id = $source_id;
     $record->target_name = $target_name;
     $record->target_id = $target_id;
     $record->save();
     $data['record'] = $record;
     return $data;
 }
Ejemplo n.º 2
0
 private function log($player, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     if (!is_null($player)) {
         $player = Player::where('GameID', $this->gameID)->where('SoldierName', $player)->first();
     }
     $command = Command::where('command_key', $command)->first();
     if ($command == 'admin_say') {
         Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => is_null($this->admin) ? null : $this->admin->PlayerID, 'logSoldierName' => is_null($this->admin) ? $this->user->username : $this->admin->SoldierName, 'logSubset' => 'Global']);
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = is_null($this->admin) ? $this->user->username : $this->admin->SoldierName;
     $record->source_id = is_null($this->admin) ? null : $this->admin->PlayerID;
     $record->target_name = is_null($player) ? 'Server' : $player->SoldierName;
     $record->target_id = is_null($player) ? null : $player->PlayerID;
     $record->save();
     return $record;
 }