From e79898084e75d4c5c98ede127a88de1d735109c5 Mon Sep 17 00:00:00 2001 From: Nexius Date: Wed, 9 Oct 2024 19:50:04 +0300 Subject: [PATCH 1/6] Extend return values for some natives --- .../Components/Pawn/Scripting/Core/Natives.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Server/Components/Pawn/Scripting/Core/Natives.cpp b/Server/Components/Pawn/Scripting/Core/Natives.cpp index 163057c9b..a2c85c4a9 100644 --- a/Server/Components/Pawn/Scripting/Core/Natives.cpp +++ b/Server/Components/Pawn/Scripting/Core/Natives.cpp @@ -270,6 +270,10 @@ SCRIPT_API(BlockIpAddress, bool(std::string const& ipAddress, int timeMS)) SCRIPT_API(UnBlockIpAddress, bool(std::string const& ipAddress)) { + if (ipAddress.empty()) + { + return false; + } BanEntry entry(ipAddress); for (INetwork* network : PawnManager::Get()->core->getNetworks()) { @@ -698,6 +702,10 @@ SCRIPT_API(SendRconCommand, bool(cell const* format)) if (console) { AmxStringFormatter command(format, GetAMX(), GetParams(), 1); + if (command.empty()) + { + return false; + } console->send(command); } return true; @@ -709,6 +717,10 @@ SCRIPT_API(SendRconCommandf, bool(cell const* format)) if (console) { AmxStringFormatter command(format, GetAMX(), GetParams(), 1); + if (command.empty()) + { + return false; + } console->send(command); } return true; @@ -723,6 +735,10 @@ SCRIPT_API(SetDeathDropAmount, bool(int amount)) SCRIPT_API(SetGameModeText, bool(cell const* format)) { AmxStringFormatter string(format, GetAMX(), GetParams(), 1); + if (string.empty()) + { + return false; + } PawnManager::Get()->core->setData(SettableCoreDataType::ModeText, string); return true; } From 2f51a98ad251bbc0743783e004369691d918ac99 Mon Sep 17 00:00:00 2001 From: Nexius Date: Wed, 9 Oct 2024 20:27:32 +0300 Subject: [PATCH 2/6] Improve `RemovePlayerWeapon` native --- Server/Source/player_impl.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index 3c618f992..3cdb6be3a 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -1342,6 +1342,16 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy PacketHelper::send(givePlayerWeaponRPC, *this); } } + NetCode::RPC::SetPlayerArmedWeapon setPlayerArmedWeaponRPC; + if (weaponid != armedWeapon_) + { + setPlayerArmedWeaponRPC.Weapon = armedWeapon_; + } + else + { + setPlayerArmedWeaponRPC.Weapon = 0; + } + PacketHelper::send(setPlayerArmedWeaponRPC, *this); } void setWeaponAmmo(WeaponSlotData weapon) override From 40536e505bf1573dbb90f066dbdfe0638d9b8e85 Mon Sep 17 00:00:00 2001 From: Nexius Date: Wed, 9 Oct 2024 21:46:04 +0300 Subject: [PATCH 3/6] Consider armed weapon in other places --- Server/Source/player_impl.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index 3cdb6be3a..c629b8f2c 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -1726,7 +1726,7 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy { if (!allowWeapons_) { - // Give the player all their weapons back. Don't worry about the armed weapon. + // Give the player all their weapons back. allowWeapons_ = true; NetCode::RPC::ResetPlayerWeapons resetWeaponsRPC; PacketHelper::send(resetWeaponsRPC, *this); @@ -1740,6 +1740,9 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy PacketHelper::send(givePlayerWeaponRPC, *this); } } + NetCode::RPC::SetPlayerArmedWeapon setPlayerArmedWeaponRPC; + setPlayerArmedWeaponRPC.Weapon = armedWeapon_; + PacketHelper::send(setPlayerArmedWeaponRPC, *this); } } else From 0ac24efb1e4fb7d406d666565ec3a9f5556e17cb Mon Sep 17 00:00:00 2001 From: Nexius Date: Fri, 11 Oct 2024 15:23:31 +0300 Subject: [PATCH 4/6] More clear message for SetTeamCount --- Server/Components/Pawn/Scripting/Core/Natives.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Server/Components/Pawn/Scripting/Core/Natives.cpp b/Server/Components/Pawn/Scripting/Core/Natives.cpp index a2c85c4a9..022f020b5 100644 --- a/Server/Components/Pawn/Scripting/Core/Natives.cpp +++ b/Server/Components/Pawn/Scripting/Core/Natives.cpp @@ -762,7 +762,8 @@ SCRIPT_API(SetNameTagDrawDistance, bool(float distance)) SCRIPT_API(SetTeamCount, bool(int count)) { - throw pawn_natives::NotImplemented(); + PawnManager::Get()->core->logLn(LogLevel::Warning, "SetTeamCount() function is removed."); + return true; } SCRIPT_API(SetWeather, bool(int weatherid)) From 18f9f37b1262c07db8b912ac31346281dc17e8cc Mon Sep 17 00:00:00 2001 From: Nexius Date: Sat, 12 Oct 2024 03:14:33 +0300 Subject: [PATCH 5/6] Invalid camera mode checks improve it once again, make a wider list --- Server/Source/player_pool.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Server/Source/player_pool.hpp b/Server/Source/player_pool.hpp index 31d4af8c1..81db9de55 100644 --- a/Server/Source/player_pool.hpp +++ b/Server/Source/player_pool.hpp @@ -870,12 +870,15 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public player.aimingData_.aspectRatio = (aimSync.AspectRatio * 1.f / 255) + 1.f; // Check for invalid camera modes - if (aimSync.CamMode < 0u || aimSync.CamMode > 65u) - aimSync.CamMode = 4u; - - // Fix for camera shaking hack // https://gtag.sannybuilder.com/sanandreas/camera-modes/ - if (aimSync.CamMode == 5u || aimSync.CamMode == 34u || (aimSync.CamMode >= 39u && aimSync.CamMode <= 43u) || aimSync.CamMode == 45u || aimSync.CamMode == 49u || aimSync.CamMode == 52u) + if (aimSync.CamMode < 3u || aimSync.CamMode == 5u || aimSync.CamMode == 6u || + (aimSync.CamMode >= 9u && aimSync.CamMode <= 13u) || aimSync.CamMode == 17u || + (aimSync.CamMode >= 19u && aimSync.CamMode <= 21u) || + (aimSync.CamMode >= 23u && aimSync.CamMode <= 28u) || + (aimSync.CamMode >= 30u && aimSync.CamMode <= 45u) || + (aimSync.CamMode >= 48u && aimSync.CamMode <= 50u) || + aimSync.CamMode == 52u || aimSync.CamMode == 54u || + aimSync.CamMode == 60u || aimSync.CamMode == 61u || aimSync.CamMode > 64u) aimSync.CamMode = 4u; aimSync.PlayerID = player.poolID; From a227fab284fb5b3248cd977f12bbd9001a3ecc16 Mon Sep 17 00:00:00 2001 From: Nexius Date: Sat, 12 Oct 2024 03:28:55 +0300 Subject: [PATCH 6/6] Try to fix format check fail --- Server/Source/player_pool.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Server/Source/player_pool.hpp b/Server/Source/player_pool.hpp index 81db9de55..e727145b3 100644 --- a/Server/Source/player_pool.hpp +++ b/Server/Source/player_pool.hpp @@ -871,14 +871,14 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public // Check for invalid camera modes // https://gtag.sannybuilder.com/sanandreas/camera-modes/ - if (aimSync.CamMode < 3u || aimSync.CamMode == 5u || aimSync.CamMode == 6u || - (aimSync.CamMode >= 9u && aimSync.CamMode <= 13u) || aimSync.CamMode == 17u || - (aimSync.CamMode >= 19u && aimSync.CamMode <= 21u) || - (aimSync.CamMode >= 23u && aimSync.CamMode <= 28u) || - (aimSync.CamMode >= 30u && aimSync.CamMode <= 45u) || - (aimSync.CamMode >= 48u && aimSync.CamMode <= 50u) || - aimSync.CamMode == 52u || aimSync.CamMode == 54u || - aimSync.CamMode == 60u || aimSync.CamMode == 61u || aimSync.CamMode > 64u) + if (aimSync.CamMode < 3u || aimSync.CamMode == 5u || aimSync.CamMode == 6u + || (aimSync.CamMode >= 9u && aimSync.CamMode <= 13u) || aimSync.CamMode == 17u + || (aimSync.CamMode >= 19u && aimSync.CamMode <= 21u) + || (aimSync.CamMode >= 23u && aimSync.CamMode <= 28u) + || (aimSync.CamMode >= 30u && aimSync.CamMode <= 45u) + || (aimSync.CamMode >= 48u && aimSync.CamMode <= 50u) + || aimSync.CamMode == 52u || aimSync.CamMode == 54u + || aimSync.CamMode == 60u || aimSync.CamMode == 61u || aimSync.CamMode > 64u) aimSync.CamMode = 4u; aimSync.PlayerID = player.poolID;