From b7fd5a57a209dd718b7a06a74138e918579ecb4d Mon Sep 17 00:00:00 2001 From: iAmir Date: Wed, 20 Dec 2023 18:28:21 +0330 Subject: [PATCH] return 0.0 if floatstr fails and throws an exception --- Server/Components/Pawn/Scripting/Core/Natives.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Server/Components/Pawn/Scripting/Core/Natives.cpp b/Server/Components/Pawn/Scripting/Core/Natives.cpp index c0a131843..163057c9b 100644 --- a/Server/Components/Pawn/Scripting/Core/Natives.cpp +++ b/Server/Components/Pawn/Scripting/Core/Natives.cpp @@ -54,7 +54,14 @@ SCRIPT_API(atan2, float(float y, float x)) SCRIPT_API(floatstr, float(std::string const& string)) { - return std::stof(string); + try + { + return std::stof(string); + } + catch (std::exception e) + { + return 0.0f; + } } SCRIPT_API(GetPlayerPoolSize, int())