Skip to content

Commit

Permalink
return 0.0 if floatstr fails and throws an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Dec 20, 2023
1 parent 66d854f commit 240e00f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Server/Components/Pawn/Scripting/Core/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 240e00f

Please sign in to comment.