mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Add the ability to specify a custom header/payload when kicking/banning a player.
This commit is contained in:
parent
4e039d415a
commit
c4e82d6756
@ -343,6 +343,10 @@ protected:
|
||||
Int32 mTrackPositionHeader; // Header to send when triggering position callback.
|
||||
Object mTrackPositionPayload; // Payload to send when triggering position callback.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mKickBanHeader; // Header to send when triggering kick/ban callback.
|
||||
Object mKickBanPayload; // Payload to send when triggering kick/ban callback.
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
Int32 mLastWeapon; // Last known weapon of the player entity.
|
||||
Float32 mLastHealth; // Last known health of the player entity.
|
||||
|
@ -94,6 +94,8 @@ void Core::ResetInst(PlayerInst & inst)
|
||||
inst.mTrackHeading = 0;
|
||||
inst.mTrackPositionHeader = 0;
|
||||
inst.mTrackPositionPayload.Release();
|
||||
inst.mKickBanHeader = 0;
|
||||
inst.mKickBanPayload.Release();
|
||||
inst.mLastWeapon = -1;
|
||||
inst.mLastHealth = 0.0;
|
||||
inst.mLastArmour = 0.0;
|
||||
|
@ -255,6 +255,21 @@ void CPlayer::Kick() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Store the default header and payload
|
||||
Core::Get().GetPlayer(m_ID).mKickBanHeader = 0;
|
||||
Core::Get().GetPlayer(m_ID).mKickBanPayload = NullObject();
|
||||
// Perform the requested operation
|
||||
_Func->KickPlayer(m_ID);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::KickBecause(Int32 header, Object & payload) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Store the specified header and payload
|
||||
Core::Get().GetPlayer(m_ID).mKickBanHeader = header;
|
||||
Core::Get().GetPlayer(m_ID).mKickBanPayload = payload;
|
||||
// Perform the requested operation
|
||||
_Func->KickPlayer(m_ID);
|
||||
}
|
||||
@ -264,6 +279,21 @@ void CPlayer::Ban() const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Store the default header and payload
|
||||
Core::Get().GetPlayer(m_ID).mKickBanHeader = 0;
|
||||
Core::Get().GetPlayer(m_ID).mKickBanPayload = NullObject();
|
||||
// Perform the requested operation
|
||||
_Func->BanPlayer(m_ID);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CPlayer::BanBecause(Int32 header, Object & payload) const
|
||||
{
|
||||
// Validate the managed identifier
|
||||
Validate();
|
||||
// Store the specified header and payload
|
||||
Core::Get().GetPlayer(m_ID).mKickBanHeader = header;
|
||||
Core::Get().GetPlayer(m_ID).mKickBanPayload = payload;
|
||||
// Perform the requested operation
|
||||
_Func->BanPlayer(m_ID);
|
||||
}
|
||||
@ -2289,6 +2319,8 @@ void Register_CPlayer(HSQUIRRELVM vm)
|
||||
.Func(_SC("StreamedFor"), &CPlayer::IsStreamedFor)
|
||||
.Func(_SC("Kick"), &CPlayer::Kick)
|
||||
.Func(_SC("Ban"), &CPlayer::Ban)
|
||||
.Func(_SC("KickBecause"), &CPlayer::KickBecause)
|
||||
.Func(_SC("BanBecause"), &CPlayer::BanBecause)
|
||||
.Func(_SC("GetOption"), &CPlayer::GetOption)
|
||||
.Func(_SC("SetOption"), &CPlayer::SetOption)
|
||||
.Func(_SC("SetOptionEx"), &CPlayer::SetOptionEx)
|
||||
|
@ -270,11 +270,21 @@ public:
|
||||
*/
|
||||
void Kick() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Kick the managed player entity from the server.
|
||||
*/
|
||||
void KickBecause(Int32 header, Object & payload) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Ban the managed player entity from the server.
|
||||
*/
|
||||
void Ban() const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Ban the managed player entity from the server.
|
||||
*/
|
||||
void BanBecause(Int32 header, Object & payload) const;
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Retrieve the key of the managed player entity.
|
||||
*/
|
||||
|
@ -257,7 +257,15 @@ static void OnPlayerDisconnect(int32_t player_id, vcmpDisconnectReason reason)
|
||||
// Attempt to forward the event
|
||||
try
|
||||
{
|
||||
Core::Get().DisconnectPlayer(player_id, reason, NullObject());
|
||||
if (reason == vcmpDisconnectReasonKick)
|
||||
{
|
||||
Core::Get().DisconnectPlayer(player_id, Core::Get().GetPlayer(player_id).mKickBanHeader,
|
||||
Core::Get().GetPlayer(player_id).mKickBanPayload);
|
||||
}
|
||||
else
|
||||
{
|
||||
Core::Get().DisconnectPlayer(player_id, reason, NullObject());
|
||||
}
|
||||
}
|
||||
SQMOD_CATCH_EVENT_EXCEPTION(OnPlayerDisconnect)
|
||||
// See if a reload was requested
|
||||
|
Loading…
Reference in New Issue
Block a user