catch FormatException in pay

(cherry picked from commit 0cc7017555)
This commit is contained in:
Alex_qp
2021-04-28 21:00:08 +02:00
committed by Siga
parent e291f561df
commit f6cfe9390f

View File

@@ -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<Player> 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)
{