Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for a couple of issues #999

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
19 changes: 18 additions & 1 deletion Server/Components/Pawn/Scripting/Core/Natives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -746,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))
Expand Down
15 changes: 14 additions & 1 deletion Server/Source/player_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1716,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);
Expand All @@ -1730,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
Expand Down
13 changes: 8 additions & 5 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading