From f6cfe9390fcadb06e10e05b4893f85a89c58c7cc Mon Sep 17 00:00:00 2001 From: Alex_qp Date: Wed, 28 Apr 2021 21:00:08 +0200 Subject: [PATCH] catch FormatException in pay (cherry picked from commit 0cc701755549950cb6b9bc939ff4d9b6fe33778f) --- .../Managers/InteractionManager.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 926dd56f..ce438abe 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using GTANetworkAPI; using Newtonsoft.Json; @@ -753,7 +753,16 @@ namespace ReallifeGamemode.Server.Managers public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount) { string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId); - int amount = Int32.Parse(stringAmount); + int amount; + try + { + amount = Int32.Parse(stringAmount); + } + catch + { + player.SendNotification("~r~" + stringAmount + " ist kein gültiger Betrag."); + return; + } Player target = PlayerService.GetPlayerByNameOrId(nameOrId); List nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player); @@ -769,7 +778,7 @@ namespace ReallifeGamemode.Server.Managers } else if (!nearbyPlayers.Contains(target)) { - player.SendNotification("~r~Dieser Spieler befindet sich nicht in deiner nähe!"); + player.SendNotification("~r~Dieser Spieler befindet sich nicht in deiner Nähe!"); } else if (player.GetUser().Handmoney < amount) {