Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/utils/localization…
Browse files Browse the repository at this point in the history
…/generate-images/axios-1.6.1
  • Loading branch information
Dutchman101 authored Jan 7, 2024
2 parents 18b1ae1 + 7201ac5 commit 153b694
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CPlayerRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ void CPlayerRPCs::LoadFunctions()
AddHandler(SET_PLAYER_NAMETAG_SHOWING, SetPlayerNametagShowing, "SetPlayerNametagShowing");
AddHandler(SET_PLAYER_TEAM, SetPlayerTeam, "SetPlayerTeam");
AddHandler(TAKE_PLAYER_SCREEN_SHOT, TakePlayerScreenShot, "TakePlayerScreenShot");
AddHandler(REMOTE_PLAYER_WEAPON_SWITCH, RemotePlayerSwitchWeapon, "RemotePlayerSwitchWeapon");
}

void CPlayerRPCs::SetPlayerMoney(NetBitStreamInterface& bitStream)
Expand Down Expand Up @@ -168,3 +169,19 @@ void CPlayerRPCs::TakePlayerScreenShot(NetBitStreamInterface& bitStream)

m_pClientGame->TakePlayerScreenShot(usSizeX, usSizeY, strTag, ucQuality, uiMaxBandwidth, usMaxPacketSize, pResource, uiServerSentTime);
}

void CPlayerRPCs::RemotePlayerSwitchWeapon(CClientEntity* pSource, NetBitStreamInterface& bitStream)
{
uint lastSlot, currentSlot;
if (bitStream.Read(lastSlot) && bitStream.Read(currentSlot))
{
CClientPlayer* pPlayer = m_pPlayerManager->Get(pSource->GetID());
if (IS_REMOTE_PLAYER(pPlayer))
{
CLuaArguments Arguments;
Arguments.PushNumber(lastSlot);
Arguments.PushNumber(currentSlot);
pPlayer->CallEvent("onClientPlayerWeaponSwitch", Arguments, true);
}
}
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/rpc/CPlayerRPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ class CPlayerRPCs : public CRPCFunctions
DECLARE_ELEMENT_RPC(SetPlayerNametagShowing);
DECLARE_ELEMENT_RPC(SetPlayerTeam);
DECLARE_RPC(TakePlayerScreenShot);
DECLARE_ELEMENT_RPC(RemotePlayerSwitchWeapon);
};
21 changes: 21 additions & 0 deletions Server/mods/deathmatch/logic/CRPCFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "CElementIDs.h"
#include "CWeaponNames.h"
#include "CPerfStatManager.h"
#include "packets/CElementRPCPacket.h"
#include "CKeyBinds.h"
#include "CStaticFunctionDefinitions.h"
#include "net/SyncStructures.h"
Expand Down Expand Up @@ -178,6 +179,26 @@ void CRPCFunctions::PlayerWeapon(NetBitStreamInterface& bitStream)
Arguments.PushNumber(m_pSourcePlayer->GetWeaponType(uiSlot));

m_pSourcePlayer->CallEvent("onPlayerWeaponSwitch", Arguments);

SViewerMapType& nearList = m_pSourcePlayer->GetNearPlayerList();
if (!nearList.empty())
{
static std::vector<CPlayer*> playersInNearList;
playersInNearList.reserve(nearList.size());
playersInNearList.clear();

for (const auto& player : nearList)
playersInNearList.push_back(player.first);

if (!playersInNearList.empty())
{
CBitStream BitStream;
BitStream.pBitStream->Write((unsigned int)ucPrevSlot);
BitStream.pBitStream->Write(uiSlot);

m_pPlayerManager->Broadcast(CElementRPCPacket(m_pSourcePlayer, REMOTE_PLAYER_WEAPON_SWITCH, *BitStream.pBitStream), playersInNearList);
}
}
}

m_pSourcePlayer->SetWeaponSlot(uiSlot);
Expand Down
1 change: 1 addition & 0 deletions Shared/sdk/net/rpc_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ enum eElementRPCFunctions
TAKE_ALL_WEAPONS,
SET_WEAPON_AMMO,
SET_WEAPON_SLOT,
REMOTE_PLAYER_WEAPON_SWITCH,

DESTROY_ALL_BLIPS,
SET_BLIP_ICON,
Expand Down

0 comments on commit 153b694

Please sign in to comment.