Skip to content

Commit

Permalink
Add IsValidWeapon native (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
shierru committed Oct 23, 2024
1 parent 01d70fb commit b876351
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Server/Components/Pawn/Scripting/Core/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Server/Source/core_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b876351

Please sign in to comment.