diff --git a/core/Bills/BillManager.php b/core/Bills/BillManager.php index 67d8778b..49c8a131 100644 --- a/core/Bills/BillManager.php +++ b/core/Bills/BillManager.php @@ -6,6 +6,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +use Maniaplanet\DedicatedServer\InvalidArgumentException; use Maniaplanet\DedicatedServer\Structures\Bill; /** @@ -57,7 +58,12 @@ class BillManager implements CallbackListener { * @return bool */ public function sendBill(callable $function, Player $player, $amount, $message, $receiver = '') { - $billId = $this->maniaControl->getClient()->sendBill($player->login, $amount, $message, $receiver); + try { + $billId = $this->maniaControl->getClient()->sendBill($player->login, intval($amount), $message, $receiver); + } catch (InvalidArgumentException $e) { + //TODO better error handling, maybe call the user func with ERROR_WHILE_TRANSACTION + return false; + } $this->openBills[$billId] = new BillData($function, $player, $amount, false, $receiver, $message); return true; } @@ -72,7 +78,11 @@ class BillManager implements CallbackListener { * @return bool */ public function sendPlanets(callable $function, $receiverLogin, $amount, $message) { - $billId = $this->maniaControl->getClient()->pay($receiverLogin, $amount, $message); + try { + $billId = $this->maniaControl->getClient()->pay($receiverLogin, intval($amount), $message); + } catch (InvalidArgumentException $e) { + return false; + } $this->openBills[$billId] = new BillData($function, $receiverLogin, $amount, true, $receiverLogin, $message); return true; } diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 2eadd20a..f0912a0d 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -42,7 +42,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener { /* * Constants */ - const VERSION = '0.156'; + const VERSION = '0.157'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2014-04-02_18_00'; const SCRIPT_TIMEOUT = 10;