Skip to content

Commit b4e4e99

Browse files
authored
Fixes for a couple of issues (#999)
* Extend return values for some natives * Improve `RemovePlayerWeapon` native * Consider armed weapon in other places * More clear message for SetTeamCount * Invalid camera mode checks improve it once again, make a wider list * Try to fix format check fail * Add fmt plugin into legacy plugin list
1 parent 5c4e67b commit b4e4e99

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

Server/Components/Pawn/PluginManager/PluginManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct BrokenPluginMessageData
1616
StringView message;
1717
};
1818

19-
static const StaticArray<BrokenPluginMessageData, 23> BrokenPlugins = {
19+
static const StaticArray<BrokenPluginMessageData, 24> BrokenPlugins = {
2020
{
2121
{ "YSF", "It requires memory hacking to run and is therefore broken on open.mp, we already added many built-in features from YSF to open.mp and the rest are coming" },
2222
{ "YSF_DL", "It requires memory hacking to run and is therefore broken on open.mp, we already added many built-in features from YSF to open.mp and the rest are coming" },
@@ -38,6 +38,7 @@ static const StaticArray<BrokenPluginMessageData, 23> BrokenPlugins = {
3838
{ "pawncmd", "There is an open.mp compatible version you can find here: https://github.com/katursis/Pawn.CMD/releases , make sure to download x.x.x-omp version." },
3939
{ "sampvoice", "There is an open.mp compatible version you can find here: https://github.com/AmyrAhmady/sampvoice/releases , make sure to download x.x.x-omp version." },
4040

41+
{ "fmt", "It is not needed anymore since open.mp has support for formatted strings in various natives" },
4142
{ "nativechecker", "It is not needed anymore since open.mp has built in native checking mechanism when a script is being loaded" },
4243
{ "samp-compat", "It is not needed anymore since open.mp has built in compat mechanism between 0.3.7 and 0.3DL versions" },
4344
{ "LFN", "It is not needed anymore since open.mp has support for longer function names, just compile your scripts with our compiler" },

Server/Components/Pawn/Scripting/Core/Natives.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ SCRIPT_API(BlockIpAddress, bool(std::string const& ipAddress, int timeMS))
270270

271271
SCRIPT_API(UnBlockIpAddress, bool(std::string const& ipAddress))
272272
{
273+
if (ipAddress.empty())
274+
{
275+
return false;
276+
}
273277
BanEntry entry(ipAddress);
274278
for (INetwork* network : PawnManager::Get()->core->getNetworks())
275279
{
@@ -698,6 +702,10 @@ SCRIPT_API(SendRconCommand, bool(cell const* format))
698702
if (console)
699703
{
700704
AmxStringFormatter command(format, GetAMX(), GetParams(), 1);
705+
if (command.empty())
706+
{
707+
return false;
708+
}
701709
console->send(command);
702710
}
703711
return true;
@@ -709,6 +717,10 @@ SCRIPT_API(SendRconCommandf, bool(cell const* format))
709717
if (console)
710718
{
711719
AmxStringFormatter command(format, GetAMX(), GetParams(), 1);
720+
if (command.empty())
721+
{
722+
return false;
723+
}
712724
console->send(command);
713725
}
714726
return true;
@@ -723,6 +735,10 @@ SCRIPT_API(SetDeathDropAmount, bool(int amount))
723735
SCRIPT_API(SetGameModeText, bool(cell const* format))
724736
{
725737
AmxStringFormatter string(format, GetAMX(), GetParams(), 1);
738+
if (string.empty())
739+
{
740+
return false;
741+
}
726742
PawnManager::Get()->core->setData(SettableCoreDataType::ModeText, string);
727743
return true;
728744
}
@@ -746,7 +762,8 @@ SCRIPT_API(SetNameTagDrawDistance, bool(float distance))
746762

747763
SCRIPT_API(SetTeamCount, bool(int count))
748764
{
749-
throw pawn_natives::NotImplemented();
765+
PawnManager::Get()->core->logLn(LogLevel::Warning, "SetTeamCount() function is removed.");
766+
return true;
750767
}
751768

752769
SCRIPT_API(SetWeather, bool(int weatherid))

Server/Source/player_impl.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,6 +1321,16 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy
13211321
PacketHelper::send(givePlayerWeaponRPC, *this);
13221322
}
13231323
}
1324+
NetCode::RPC::SetPlayerArmedWeapon setPlayerArmedWeaponRPC;
1325+
if (weaponid != armedWeapon_)
1326+
{
1327+
setPlayerArmedWeaponRPC.Weapon = armedWeapon_;
1328+
}
1329+
else
1330+
{
1331+
setPlayerArmedWeaponRPC.Weapon = 0;
1332+
}
1333+
PacketHelper::send(setPlayerArmedWeaponRPC, *this);
13241334
}
13251335

13261336
void setWeaponAmmo(WeaponSlotData weapon) override
@@ -1691,7 +1701,7 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy
16911701
{
16921702
if (!allowWeapons_)
16931703
{
1694-
// Give the player all their weapons back. Don't worry about the armed weapon.
1704+
// Give the player all their weapons back.
16951705
allowWeapons_ = true;
16961706
NetCode::RPC::ResetPlayerWeapons resetWeaponsRPC;
16971707
PacketHelper::send(resetWeaponsRPC, *this);
@@ -1705,6 +1715,9 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy
17051715
PacketHelper::send(givePlayerWeaponRPC, *this);
17061716
}
17071717
}
1718+
NetCode::RPC::SetPlayerArmedWeapon setPlayerArmedWeaponRPC;
1719+
setPlayerArmedWeaponRPC.Weapon = armedWeapon_;
1720+
PacketHelper::send(setPlayerArmedWeaponRPC, *this);
17081721
}
17091722
}
17101723
else

Server/Source/player_pool.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,15 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public
871871
player.aimingData_.aspectRatio = (aimSync.AspectRatio * 1.f / 255) + 1.f;
872872

873873
// Check for invalid camera modes
874-
if (aimSync.CamMode < 0u || aimSync.CamMode > 65u)
875-
aimSync.CamMode = 4u;
876-
877-
// Fix for camera shaking hack
878874
// https://gtag.sannybuilder.com/sanandreas/camera-modes/
879-
if (aimSync.CamMode == 5u || aimSync.CamMode == 34u || (aimSync.CamMode >= 39u && aimSync.CamMode <= 43u) || aimSync.CamMode == 45u || aimSync.CamMode == 49u || aimSync.CamMode == 52u)
875+
if (aimSync.CamMode < 3u || aimSync.CamMode == 5u || aimSync.CamMode == 6u
876+
|| (aimSync.CamMode >= 9u && aimSync.CamMode <= 13u) || aimSync.CamMode == 17u
877+
|| (aimSync.CamMode >= 19u && aimSync.CamMode <= 21u)
878+
|| (aimSync.CamMode >= 23u && aimSync.CamMode <= 28u)
879+
|| (aimSync.CamMode >= 30u && aimSync.CamMode <= 45u)
880+
|| (aimSync.CamMode >= 48u && aimSync.CamMode <= 50u)
881+
|| aimSync.CamMode == 52u || aimSync.CamMode == 54u
882+
|| aimSync.CamMode == 60u || aimSync.CamMode == 61u || aimSync.CamMode > 64u)
880883
aimSync.CamMode = 4u;
881884

882885
aimSync.PlayerID = player.poolID;

0 commit comments

Comments
 (0)