From fa14d96111d685bda71cde5aa7d0925b7dda5a9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Sun, 15 Jun 2014 00:21:30 +0200 Subject: [PATCH] prevent error on missing record id --- application/plugins/MCTeam/LocalRecordsPlugin.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/application/plugins/MCTeam/LocalRecordsPlugin.php b/application/plugins/MCTeam/LocalRecordsPlugin.php index 98040c0d..5d2f3655 100644 --- a/application/plugins/MCTeam/LocalRecordsPlugin.php +++ b/application/plugins/MCTeam/LocalRecordsPlugin.php @@ -631,13 +631,13 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList return; } - $chatCommand = explode(' ', $chat[1][2]); - $recordId = (int)$chatCommand[1]; - if ($recordId <= 0) { - $this->maniaControl->chat->sendError('No Record ID given!', $player); + $commandParts = explode(' ', $chat[1][2]); + if (count($commandParts) < 2) { + $this->maniaControl->chat->sendUsageInfo('Missing Record ID! (Example: //delrec 3)', $player); return; } + $recordId = (int)$commandParts[1]; $currentMap = $this->maniaControl->mapManager->getCurrentMap(); $records = $this->getLocalRecords($currentMap); if (count($records) < $recordId) { @@ -646,7 +646,9 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } $mysqli = $this->maniaControl->database->mysqli; - $query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = {$currentMap->index} AND `playerIndex` = {$player->index};"; + $query = "DELETE FROM `" . self::TABLE_RECORDS . "` + WHERE `mapIndex` = {$currentMap->index} + AND `playerIndex` = {$player->index};"; $mysqli->query($query); if ($mysqli->error) { trigger_error($mysqli->error);