Clamp ping instead of throwing error

This commit is contained in:
FutureRave 2022-03-02 11:46:02 +00:00
parent 8847b362a7
commit 9e207b3c9a
No known key found for this signature in database
GPG Key ID: E883E2BC9657D955

View File

@ -119,13 +119,9 @@ namespace Components
{
Script::AddFunction("SetPing", [](Game::scr_entref_t entref) // gsc: self SetPing(<int>)
{
const auto ping = Game::Scr_GetInt(0);
auto ping = Game::Scr_GetInt(0);
if (ping < 0 || ping > 999)
{
Game::Scr_ParamError(0, "^1SetPing: Ping needs to be between 0 and 999!\n");
return;
}
ping = std::clamp(ping, 0, 999);
const auto* ent = Game::GetPlayerEntity(entref);
auto* client = Script::GetClient(ent);