Merge branch 'cherry-pick-0cc70175' into 'master'

catch FormatException in pay

See merge request log-gtav/reallife-gamemode!65
This commit is contained in:
Siga
2021-04-29 00:13:34 +00:00

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using GTANetworkAPI; using GTANetworkAPI;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -753,7 +753,16 @@ namespace ReallifeGamemode.Server.Managers
public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount) public void InteractionMenu_Pay(Player player, string jsonNameOrId, string stringAmount)
{ {
string nameOrId = (string)JsonConvert.DeserializeObject(jsonNameOrId); 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); Player target = PlayerService.GetPlayerByNameOrId(nameOrId);
List<Player> nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player); List<Player> nearbyPlayers = NAPI.Player.GetPlayersInRadiusOfPlayer(3, player);
@@ -769,7 +778,7 @@ namespace ReallifeGamemode.Server.Managers
} }
else if (!nearbyPlayers.Contains(target)) 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) else if (player.GetUser().Handmoney < amount)
{ {