diff --git a/Server/Components/Pawn/Scripting/Core/Natives.cpp b/Server/Components/Pawn/Scripting/Core/Natives.cpp index 163057c9b..37a92546e 100644 --- a/Server/Components/Pawn/Scripting/Core/Natives.cpp +++ b/Server/Components/Pawn/Scripting/Core/Natives.cpp @@ -600,6 +600,11 @@ SCRIPT_API(GetWeaponName, bool(int weaponid, OutputOnlyString& weapon)) return true; } +SCRIPT_API(IsValidWeapon, bool(int weaponid)) +{ + return PawnManager::Get()->core->isWeaponValid(PlayerWeapon(weaponid)); +} + SCRIPT_API(LimitGlobalChatRadius, bool(float chatRadius)) { *PawnManager::Get()->config->getBool("game.use_chat_radius") = true; diff --git a/Server/Source/core_impl.hpp b/Server/Source/core_impl.hpp index 110b6c9fd..65cbf48fa 100644 --- a/Server/Source/core_impl.hpp +++ b/Server/Source/core_impl.hpp @@ -1995,6 +1995,16 @@ class Core final : public ICore, public PlayerConnectEventHandler, public Consol return PlayerWeaponNames[index]; } + bool isWeaponValid(PlayerWeapon weapon) override + { + int index = int(weapon); + + if (weapon < 0 || weapon > PlayerWeapon_End) + return false; + + return true; + } + void onPlayerConnect(IPlayer& player) override { playerInit(player);