2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Player.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Entity/Vehicle.hpp"
|
2015-10-29 21:11:30 +01:00
|
|
|
#include "Base/Color3.hpp"
|
2016-06-19 07:13:02 +02:00
|
|
|
#include "Base/Color4.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Vector3.hpp"
|
2021-01-30 07:51:39 +01:00
|
|
|
#include "Library/IO/Buffer.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Core.hpp"
|
2021-01-30 07:51:39 +01:00
|
|
|
#include "Core/Areas.hpp"
|
|
|
|
#include "Core/Tasks.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-06-19 18:06:24 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
extern SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, int32_t idx, uint32_t & color, int32_t & msgidx);
|
2016-06-19 18:06:24 +02:00
|
|
|
|
2016-11-15 20:16:24 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
SQMOD_DECL_TYPENAME(Typename, _SC("SqPlayer"))
|
2016-11-15 20:16:24 +01:00
|
|
|
|
2015-10-29 21:11:30 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
SQChar CPlayer::s_Buffer[SQMOD_PLAYER_TMP_BUFFER];
|
2015-11-01 00:32:41 +01:00
|
|
|
|
2015-11-07 11:17:39 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t CPlayer::Max = SQMOD_PLAYER_POOL;
|
2015-11-07 11:17:39 +01:00
|
|
|
|
2016-08-07 00:54:33 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::SqGetNull(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-04-17 16:42:09 +02:00
|
|
|
sq_pushobject(vm, Core::Get().GetNullPlayer().GetObj());
|
2016-08-07 00:54:33 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::GetNull()
|
2016-08-07 00:54:33 +02:00
|
|
|
{
|
|
|
|
return Core::Get().GetNullPlayer();
|
|
|
|
}
|
|
|
|
|
2015-11-09 04:54:03 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer::CPlayer(int32_t id)
|
2016-02-20 23:25:00 +01:00
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PLAYER_POOL))
|
2021-01-30 07:51:39 +01:00
|
|
|
, m_Tag(fmt::format("{}", id)), m_Data(), m_Buffer(256), m_CircularLocks(0)
|
2016-05-22 05:20:38 +02:00
|
|
|
, mBufferInitSize(256)
|
|
|
|
, mMessageColor(0x6599FFFF)
|
|
|
|
, mAnnounceStyle(1)
|
|
|
|
, mDefaultAmmo(0)
|
2021-01-30 07:51:39 +01:00
|
|
|
, mMessagePrefix()
|
|
|
|
, mMessagePostfix()
|
|
|
|
, mAnnouncePrefix()
|
|
|
|
, mAnnouncePostfix()
|
2016-05-22 05:20:38 +02:00
|
|
|
, mMessagePrefixes()
|
|
|
|
, mLimitPrefixPostfixMessage(true)
|
|
|
|
{
|
|
|
|
// Reset message prefixes
|
2021-01-30 07:51:39 +01:00
|
|
|
for (auto & prefix : mMessagePrefixes)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
prefix.assign(_SC(""));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CPlayer::ToString() const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CPlayer::GetTag() const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::SetTag(StackStrF & tag)
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-11-16 13:49:04 +01:00
|
|
|
if (tag.mLen > 0)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
m_Tag.assign(tag.mPtr, static_cast< size_t >(tag.mLen));
|
2016-11-16 13:49:04 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_Tag.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
CPlayer & CPlayer::ApplyTag(StackStrF & tag)
|
2016-11-16 13:49:04 +01:00
|
|
|
{
|
|
|
|
SetTag(tag);
|
|
|
|
return *this;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::GetData()
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return m_Data;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::SetData(LightObj & data)
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Apply the specified value
|
|
|
|
m_Data = data;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::GetEvents() const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-02-21 20:24:59 +01:00
|
|
|
// Return the associated event table
|
|
|
|
return Core::Get().GetPlayer(m_ID).mEvents;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-07-26 23:13:50 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::CustomEvent(int32_t header, LightObj & payload) const
|
2016-07-26 23:13:50 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2021-01-30 07:51:39 +01:00
|
|
|
// Perform the requested action
|
2016-07-26 23:13:50 +02:00
|
|
|
Core::Get().EmitPlayerCustom(m_ID, header, payload);
|
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::IsConnected() const
|
|
|
|
{
|
|
|
|
return _Func->IsPlayerConnected(m_ID);
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:11:30 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CPlayer::IsStreamedFor(CPlayer & player) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerStreamedForPlayer(m_ID, player.GetID());
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
bool CPlayer::GetAdmin() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerAdmin(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:40:48 +02:00
|
|
|
void CPlayer::SetAdmin(bool toggle)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:40:48 +02:00
|
|
|
// Grab the current value for this property
|
|
|
|
const bool current = _Func->IsPlayerAdmin(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == toggle)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ADMIN))
|
2016-08-17 14:40:48 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ADMIN);
|
2016-08-17 14:40:48 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerAdmin(m_ID, current, toggle);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerAdmin(m_ID, static_cast< uint8_t >(toggle));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const SQChar * CPlayer::GetIP() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear any previous string (just in case)
|
|
|
|
s_Buffer[0] = '\0';
|
2016-06-14 03:42:18 +02:00
|
|
|
// Query the server for the IP of the managed player
|
2016-05-22 05:20:38 +02:00
|
|
|
if (_Func->GetPlayerIP(m_ID, s_Buffer, sizeof(s_Buffer)) == vcmpErrorBufferTooSmall)
|
|
|
|
{
|
2016-06-14 03:42:18 +02:00
|
|
|
STHROWF("The available buffer was too small to contain the IP address");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Return the requested information
|
|
|
|
return s_Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const SQChar * CPlayer::GetUID() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear any previous string (just in case)
|
|
|
|
s_Buffer[0] = '\0';
|
2016-06-14 03:42:18 +02:00
|
|
|
// Query the server for the UID of the managed player
|
2016-05-22 05:20:38 +02:00
|
|
|
if (_Func->GetPlayerUID(m_ID, s_Buffer, sizeof(s_Buffer)) == vcmpErrorBufferTooSmall)
|
|
|
|
{
|
|
|
|
STHROWF("The available buffer was too small to contain the unique id");
|
|
|
|
}
|
|
|
|
// Return the requested information
|
|
|
|
return s_Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const SQChar * CPlayer::GetUID2() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Clear any previous string (just in case)
|
|
|
|
s_Buffer[0] = '\0';
|
2016-06-14 03:42:18 +02:00
|
|
|
// Query the server for the UID2 of the managed player
|
2016-05-22 05:20:38 +02:00
|
|
|
if (_Func->GetPlayerUID2(m_ID, s_Buffer, sizeof(s_Buffer)) == vcmpErrorBufferTooSmall)
|
|
|
|
{
|
2016-06-14 03:42:18 +02:00
|
|
|
STHROWF("The available buffer was too small to contain the unique id v2");
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2015-10-29 21:11:30 +01:00
|
|
|
return s_Buffer;
|
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::Kill() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->KillPlayer(m_ID);
|
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::Kick() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 12:48:29 +02:00
|
|
|
// Store the default header and payload
|
2016-10-25 15:08:23 +02:00
|
|
|
Core::Get().GetPlayer(m_ID).mKickBanHeader = vcmpDisconnectReasonKick;
|
2017-02-21 20:24:59 +01:00
|
|
|
Core::Get().GetPlayer(m_ID).mKickBanPayload = NullLightObj();
|
2016-08-17 12:48:29 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
_Func->KickPlayer(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::KickBecause(int32_t header, LightObj & payload) const
|
2016-08-17 12:48:29 +02:00
|
|
|
{
|
|
|
|
// 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;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
|
|
|
_Func->KickPlayer(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::Ban() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 12:48:29 +02:00
|
|
|
// Store the default header and payload
|
2016-10-25 15:08:23 +02:00
|
|
|
Core::Get().GetPlayer(m_ID).mKickBanHeader = vcmpDisconnectReasonKick;
|
2017-02-21 20:24:59 +01:00
|
|
|
Core::Get().GetPlayer(m_ID).mKickBanPayload = NullLightObj();
|
2016-08-17 12:48:29 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
_Func->BanPlayer(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::BanBecause(int32_t header, LightObj & payload) const
|
2016-08-17 12:48:29 +02:00
|
|
|
{
|
|
|
|
// 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;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
|
|
|
_Func->BanPlayer(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t CPlayer::GetKey() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerKey(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const SQChar * CPlayer::GetName() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear any previous string (just in case)
|
|
|
|
s_Buffer[0] = '\0';
|
|
|
|
// Query the server for the name of the managed player
|
|
|
|
if (_Func->GetPlayerName(m_ID, s_Buffer, sizeof(s_Buffer)) == vcmpErrorBufferTooSmall)
|
|
|
|
{
|
|
|
|
STHROWF("The available buffer was too small to contain the nickname");
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return s_Buffer;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::SetName(StackStrF & name) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-11-16 13:49:04 +01:00
|
|
|
const vcmpError ret = _Func->SetPlayerName(m_ID, name.mPtr);
|
2016-08-27 03:03:24 +02:00
|
|
|
// Validate the resulted status
|
|
|
|
if (ret == vcmpErrorNullArgument)
|
|
|
|
{
|
|
|
|
STHROWF("Cannot assign a null name to a player");
|
|
|
|
}
|
|
|
|
else if (ret == vcmpErrorInvalidName)
|
2016-05-24 07:26:47 +02:00
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("The specified name is invalid: {}", name.mPtr);
|
2016-05-24 07:26:47 +02:00
|
|
|
}
|
2016-08-27 03:03:24 +02:00
|
|
|
else if (ret == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("The specified name is too large: {}", name.mLen);
|
2016-08-27 03:03:24 +02:00
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetState() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerState(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetOption(int32_t option_id) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id));
|
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid option identifier: {}", option_id);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Return the requested value
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetOption(int32_t option_id, bool toggle)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
SetOptionEx(option_id, toggle, 0, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetOptionEx(int32_t option_id, bool toggle, int32_t header, LightObj & payload)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-08-17 14:31:45 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Grab the current value for this property
|
|
|
|
const bool current = _Func->GetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id));
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == toggle)
|
2016-06-14 03:42:18 +02:00
|
|
|
{
|
2016-08-17 14:31:45 +02:00
|
|
|
return;
|
2016-06-14 03:42:18 +02:00
|
|
|
}
|
2016-08-17 14:31:45 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_OPTION))
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_OPTION);
|
2016-06-14 03:42:18 +02:00
|
|
|
// Now forward the event call
|
2016-08-17 14:31:45 +02:00
|
|
|
Core::Get().EmitPlayerOption(m_ID, option_id, current, header, payload);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
if (_Func->SetPlayerOption(m_ID,
|
|
|
|
static_cast< vcmpPlayerOption >(option_id),
|
|
|
|
static_cast< uint8_t >(toggle)) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: {}", option_id);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-08-13 17:29:09 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
SQFloat CPlayer::GetNetworkStatisticsF(int32_t option_id) const
|
2019-08-13 17:29:09 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2019-08-13 17:34:09 +02:00
|
|
|
// Retrieve the requested information
|
|
|
|
double value = _Func->GetNetworkStatistics(m_ID, static_cast< vcmpNetworkStatisticsOption >(option_id));
|
|
|
|
// Return it in the proper type
|
|
|
|
return static_cast< SQFloat >(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
SQInteger CPlayer::GetNetworkStatisticsI(int32_t option_id) const
|
2019-08-13 17:34:09 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Retrieve the requested information
|
|
|
|
double value = _Func->GetNetworkStatistics(m_ID, static_cast< vcmpNetworkStatisticsOption >(option_id));
|
|
|
|
// Return it in the proper type
|
|
|
|
return static_cast< SQInteger >(value);
|
2019-08-13 17:29:09 +02:00
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetWorld() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerWorld(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetWorld(int32_t world)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:45:44 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerWorld(m_ID);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
2016-08-17 14:45:44 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerWorld(m_ID, current, world, false);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerWorld(m_ID, world);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetSecondaryWorld() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerSecondaryWorld(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetSecondaryWorld(int32_t world)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:45:44 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerSecondaryWorld(m_ID);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WORLD))
|
2016-08-17 14:45:44 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WORLD);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerWorld(m_ID, current, world, true);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerSecondaryWorld(m_ID, world);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetUniqueWorld() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerUniqueWorld(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
bool CPlayer::IsWorldCompatible(int32_t world) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerWorldCompatible(m_ID, world);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetClass() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerClass(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetTeam() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerTeam(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetTeam(int32_t team)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:49:08 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerTeam(m_ID);
|
2016-08-17 14:49:08 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == team)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_TEAM))
|
2016-08-17 14:49:08 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_TEAM);
|
2016-08-17 14:49:08 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerTeam(m_ID, current, team);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
if (_Func->SetPlayerTeam(m_ID, team) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid team identifier: {}", team);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetSkin() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerSkin(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetSkin(int32_t skin)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:52:22 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerSkin(m_ID);
|
2016-08-17 14:52:22 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == skin)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SKIN))
|
2016-08-17 14:52:22 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_SKIN);
|
2016-08-17 14:52:22 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerSkin(m_ID, current, skin);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid skin identifier: {}", skin);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Color3 CPlayer::GetColor() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create an empty color
|
|
|
|
Color3 color;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the color values
|
2017-08-06 20:15:32 +02:00
|
|
|
color.SetRGB(_Func->GetPlayerColour(m_ID));
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return color;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::SetColor(const Color3 & color) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerColour(m_ID, color.GetRGB());
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetColorEx(uint8_t r, uint8_t g, uint8_t b) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2020-03-22 09:00:31 +01:00
|
|
|
_Func->SetPlayerColour(m_ID, SQMOD_PACK_RGB(r, g, b)); // NOLINT(hicpp-signed-bitwise)
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::IsSpawned() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerSpawned(m_ID);
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::ForceSpawn() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->ForcePlayerSpawn(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::ForceSelect() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->ForcePlayerSelect(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::IsTyping() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerTyping(m_ID);
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetMoney() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerMoney(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetMoney(int32_t amount)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:55:59 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerMoney(m_ID);
|
2016-08-17 14:55:59 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == amount)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
2016-08-17 14:55:59 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_MONEY);
|
2016-08-17 14:55:59 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerMoney(m_ID, current, amount);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerMoney(m_ID, amount);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::GiveMoney(int32_t amount)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 14:55:59 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerMoney(m_ID);
|
2016-08-17 14:55:59 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_MONEY))
|
2016-08-17 14:55:59 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_MONEY);
|
2016-08-17 14:55:59 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerMoney(m_ID, current, current + amount);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->GivePlayerMoney(m_ID, amount);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetScore() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerScore(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetScore(int32_t score)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 15:00:28 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerScore(m_ID);
|
2016-08-17 15:00:28 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == score)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_SCORE))
|
2016-08-17 15:00:28 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_SCORE);
|
2016-08-17 15:00:28 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerScore(m_ID, current, score);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerScore(m_ID, score);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetWantedLevel() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerWantedLevel(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetWantedLevel(int32_t level)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 15:04:14 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerWantedLevel(m_ID);
|
2016-08-17 15:04:14 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == level)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_WANTED_LEVEL))
|
2016-08-17 15:04:14 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_WANTED_LEVEL);
|
2016-08-17 15:04:14 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerWantedLevel(m_ID, current, level);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerWantedLevel(m_ID, level);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetPing() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerPing(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2020-03-22 09:00:31 +01:00
|
|
|
SQFloat CPlayer::GetFPS() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2020-03-22 09:00:31 +01:00
|
|
|
return static_cast< SQFloat >(_Func->GetPlayerFPS(m_ID));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetHealth() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerHealth(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetHealth(float amount) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerHealth(m_ID, amount);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetArmor() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerArmour(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetArmor(float amount) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerArmour(m_ID, amount);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-07-23 16:29:23 +02:00
|
|
|
uint32_t CPlayer::GetImmunity() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerImmunityFlags(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-07-23 16:29:23 +02:00
|
|
|
void CPlayer::SetImmunity(uint32_t flags)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 15:07:31 +02:00
|
|
|
// Grab the current value for this property
|
2021-07-23 16:29:23 +02:00
|
|
|
const uint32_t current = _Func->GetPlayerImmunityFlags(m_ID);
|
2016-08-17 15:07:31 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_IMMUNITY))
|
2016-08-17 15:07:31 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_IMMUNITY);
|
2016-08-17 15:07:31 +02:00
|
|
|
// Now forward the event call
|
2021-07-23 16:29:23 +02:00
|
|
|
Core::Get().EmitPlayerImmunity(m_ID, static_cast< int32_t >(current), static_cast< int32_t >(flags));
|
2016-08-17 15:07:31 +02:00
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerImmunityFlags(m_ID, static_cast< uint32_t >(flags));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Vector3 CPlayer::GetPosition() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetPlayerPosition(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::SetPosition(const Vector3 & pos) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, pos.x, pos.y, pos.z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetPositionEx(float x, float y, float z) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, x, y, z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Vector3 CPlayer::GetSpeed() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the speed values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetPlayerSpeed(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::SetSpeed(const Vector3 & vel) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerSpeed(m_ID, vel.x, vel.y, vel.z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetSpeedEx(float x, float y, float z) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerSpeed(m_ID, x, y, z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::AddSpeed(const Vector3 & vel) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->AddPlayerSpeed(m_ID, vel.x, vel.y, vel.z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::AddSpeedEx(float x, float y, float z) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->AddPlayerSpeed(m_ID, x, y, z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetHeading() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerHeading(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetHeading(float angle) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerHeading(m_ID, angle);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetAlpha() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerAlpha(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetAlpha(int32_t alpha)
|
2016-06-20 07:08:33 +02:00
|
|
|
{
|
2016-08-17 15:10:43 +02:00
|
|
|
SetAlphaEx(alpha, 0);
|
2016-06-20 07:08:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetAlphaEx(int32_t alpha, int32_t fade)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-08-17 15:10:43 +02:00
|
|
|
// Grab the current value for this property
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t current = _Func->GetPlayerAlpha(m_ID);
|
2016-08-17 15:10:43 +02:00
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == alpha)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
2021-09-12 15:03:31 +02:00
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_ALPHA))
|
2016-08-17 15:10:43 +02:00
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
2016-08-18 13:20:41 +02:00
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_ALPHA);
|
2016-08-17 15:10:43 +02:00
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerAlpha(m_ID, current, alpha, fade);
|
|
|
|
}
|
2021-09-12 14:49:29 +02:00
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
_Func->SetPlayerAlpha(m_ID, alpha, static_cast< uint32_t >(fade));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Vector3 CPlayer::GetAimPosition() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetPlayerAimPosition(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 20:15:32 +02:00
|
|
|
Vector3 CPlayer::GetAimDirection() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Create a default vector instance
|
|
|
|
Vector3 vec;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the direction values
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->GetPlayerAimDirection(m_ID, &vec.x, &vec.y, &vec.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return vec;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
bool CPlayer::IsBurning() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->IsPlayerOnFire(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
bool CPlayer::IsCrouched() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->IsPlayerCrouching(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetAction() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerAction(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-07-23 16:29:23 +02:00
|
|
|
uint32_t CPlayer::GetGameKeys() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerGameKeys(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-09-12 14:49:29 +02:00
|
|
|
bool CPlayer::Embark(CVehicle & vehicle)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Is the specified vehicle even valid?
|
|
|
|
if (!vehicle.IsActive())
|
|
|
|
{
|
|
|
|
STHROWF("Invalid vehicle argument: null");
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2021-09-12 14:49:29 +02:00
|
|
|
// If the player embarks in the same vehicle then ignore
|
|
|
|
if (_Func->GetPlayerVehicleId(m_ID) == vehicle.GetID())
|
|
|
|
{
|
|
|
|
return true; // I guess this is somewhat successful
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_EMBARK))
|
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_EMBARK);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerEmbarking(m_ID, vehicle.GetID(), 0);
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2020-03-22 09:00:31 +01:00
|
|
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0,
|
|
|
|
static_cast< uint8_t >(true), static_cast< uint8_t >(true)) != vcmpErrorRequestDenied);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-09-12 14:49:29 +02:00
|
|
|
bool CPlayer::EmbarkEx(CVehicle & vehicle, int32_t slot, bool allocate, bool warp)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Is the specified vehicle even valid?
|
|
|
|
if (!vehicle.IsActive())
|
|
|
|
{
|
|
|
|
STHROWF("Invalid vehicle argument: null");
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2021-09-12 14:49:29 +02:00
|
|
|
// If the player embarks in the same vehicle then ignore
|
|
|
|
if (_Func->GetPlayerVehicleId(m_ID) == vehicle.GetID())
|
|
|
|
{
|
|
|
|
return true; // I guess this is somewhat successful
|
|
|
|
}
|
|
|
|
// Avoid infinite recursive event loops
|
|
|
|
else if (!(m_CircularLocks & PLAYERCL_EMIT_PLAYER_EMBARK))
|
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PLAYERCL_EMIT_PLAYER_EMBARK);
|
|
|
|
// Now forward the event call
|
|
|
|
Core::Get().EmitPlayerEmbarking(m_ID, vehicle.GetID(), slot);
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
2020-03-22 09:00:31 +01:00
|
|
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot,
|
|
|
|
static_cast< uint8_t >(allocate), static_cast< uint8_t >(warp)) != vcmpErrorRequestDenied);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::Disembark() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->RemovePlayerFromVehicle(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetVehicleStatus() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerInVehicleStatus(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetVehicleSlot() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerInVehicleSlot(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::GetVehicle() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-06-14 01:34:04 +02:00
|
|
|
// Retrieve the identifier of the vehicle
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t id = _Func->GetPlayerVehicleId(m_ID);
|
2016-06-14 01:34:04 +02:00
|
|
|
// Validate the obtained identifier
|
|
|
|
if (VALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
|
|
|
|
{
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetVehicle(id).mObj;
|
|
|
|
}
|
|
|
|
// Default to a null object
|
2017-08-06 17:14:58 +02:00
|
|
|
return Core::Get().GetNullVehicle();
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetVehicleID() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerVehicleId(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetWeapon() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerWeapon(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetWeapon(int32_t wep) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
if (_Func->SetPlayerWeapon(m_ID, wep, mDefaultAmmo) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon identifier: {}", wep);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetWeaponEx(int32_t wep, int32_t ammo) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
if (_Func->SetPlayerWeapon(m_ID, wep, ammo) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon ammo: {}", ammo);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::GiveWeapon(int32_t wep, int32_t ammo) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
if (_Func->GivePlayerWeapon(m_ID, wep, ammo) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon ammo: {}", ammo);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetAmmo() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerWeaponAmmo(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetWeaponSlot() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
|
|
|
return _Func->GetPlayerWeaponSlot(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetWeaponSlot(int32_t slot) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
if (_Func->SetPlayerWeaponSlot(m_ID, slot) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon slot: {}", slot);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetWeaponAtSlot(int32_t slot) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to obtain the weapon identifier of the specified slot
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t id = _Func->GetPlayerWeaponAtSlot(m_ID, slot);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon slot: {}", slot);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
// Return the requested information
|
|
|
|
return id;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetAmmoAtSlot(int32_t slot) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to obtain the weapon ammo of the specified slot
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t ammo = _Func->GetPlayerAmmoAtSlot(m_ID, slot);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid weapon slot: {}", slot);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return ammo;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::RemoveWeapon(int32_t wep) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->RemovePlayerWeapon(m_ID, wep);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StripWeapons() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
_Func->RemoveAllWeapons(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetCameraPosition(const Vector3 & pos, const Vector3 & aim) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCameraPosition(m_ID, pos.x, pos.y, pos.z, aim.x, aim.y, aim.z);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetCameraPositionEx(float xp, float yp, float zp, float xa, float ya, float za) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetCameraPosition(m_ID, xp, yp, zp, xa, ya, za);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::RestoreCamera() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->RestoreCamera(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
bool CPlayer::IsCameraLocked() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsCameraLocked(m_ID);
|
2015-11-11 08:02:42 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetAnimation(int32_t anim) const
|
2016-06-15 05:06:03 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerAnimation(m_ID, 0, anim);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetAnimationEx(int32_t anim, int32_t group) const
|
2015-11-11 08:02:42 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerAnimation(m_ID, group, anim);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::StandingOnVehicle() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-06-14 01:34:04 +02:00
|
|
|
// Retrieve the identifier of the vehicle
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t id = _Func->GetPlayerStandingOnVehicle(m_ID);
|
2016-06-14 01:34:04 +02:00
|
|
|
// Validate the obtained identifier
|
|
|
|
if (VALID_ENTITYEX(id, SQMOD_VEHICLE_POOL))
|
|
|
|
{
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetVehicle(id).mObj;
|
|
|
|
}
|
|
|
|
// Default to a null object
|
2017-08-06 17:14:58 +02:00
|
|
|
return Core::Get().GetNullVehicle();
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::StandingOnObject() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-06-14 01:34:04 +02:00
|
|
|
// Retrieve the identifier of the object
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t id = _Func->GetPlayerStandingOnObject(m_ID);
|
2016-06-14 01:34:04 +02:00
|
|
|
// Validate the obtained identifier
|
|
|
|
if (VALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
|
|
|
|
{
|
|
|
|
// Return the requested information
|
2020-04-17 16:42:09 +02:00
|
|
|
return Core::Get().GetObj(id).mObj;
|
2016-06-14 01:34:04 +02:00
|
|
|
}
|
|
|
|
// Default to a null object
|
2017-08-06 17:14:58 +02:00
|
|
|
return Core::Get().GetNullObject();
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
bool CPlayer::IsAway() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
|
|
|
return _Func->IsPlayerAway(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::GetSpectator() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-06-15 05:11:47 +02:00
|
|
|
// Retrieve the identifier of the player
|
2021-01-30 07:51:39 +01:00
|
|
|
const int32_t id = _Func->GetPlayerSpectateTarget(m_ID);
|
2016-06-15 05:11:47 +02:00
|
|
|
// Validated the obtained identifier
|
|
|
|
if (_Func->GetLastError() != vcmpErrorNoSuchEntity && VALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetPlayer(id).mObj;
|
|
|
|
}
|
|
|
|
// Default to a null object
|
2017-08-06 17:14:58 +02:00
|
|
|
return Core::Get().GetNullPlayer();
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 14:14:45 +02:00
|
|
|
void CPlayer::SetSpectator(CPlayer & target) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 14:14:45 +02:00
|
|
|
// Spectate the given target
|
|
|
|
_Func->SetPlayerSpectateTarget(m_ID, target.GetID());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetSpectatorID() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Retrieve the identifier of the player
|
|
|
|
return _Func->GetPlayerSpectateTarget(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetSpectatorID(SQInteger id) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
2020-03-22 09:00:31 +01:00
|
|
|
_Func->SetPlayerSpectateTarget(m_ID, static_cast< int32_t >(id));
|
2017-08-06 14:14:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 17:24:42 +02:00
|
|
|
void CPlayer::Unspectate() const
|
2017-08-06 14:14:45 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
|
|
|
_Func->SetPlayerSpectateTarget(m_ID, -1);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetPlayer3DArrow(CPlayer & target, bool toggle) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
|
|
|
_Func->SetPlayer3DArrowForPlayer(m_ID, target.GetID(), toggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::GetPlayer3DArrow(CPlayer & target) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
|
|
|
return _Func->GetPlayer3DArrowForPlayer(m_ID, target.GetID());
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetPlayer3DArrowID(SQInteger id, bool toggle) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
|
|
|
_Func->SetPlayer3DArrowForPlayer(m_ID, id, toggle);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::GetPlayer3DArrowID(SQInteger id) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Spectate the given target
|
|
|
|
return _Func->GetPlayer3DArrowForPlayer(m_ID, id);
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
bool CPlayer::InterpolateCameraLookAt(const Vector3 & pos, uint32_t ms) const
|
2019-06-01 23:39:06 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->InterpolateCameraLookAt(m_ID, pos.x, pos.y, pos.z, ms) != vcmpErrorRequestDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
bool CPlayer::InterpolateCameraLookAtEx(float x, float y, float z, uint32_t ms) const
|
2019-06-01 23:39:06 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->InterpolateCameraLookAt(m_ID, x, y, z, ms) != vcmpErrorRequestDenied;
|
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::Redirect(StackStrF & ip, uint32_t port, StackStrF & nick,
|
|
|
|
StackStrF & server_pass, StackStrF & user_pass) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-11-16 13:49:04 +01:00
|
|
|
if (_Func->RedirectPlayerToServer(m_ID, ip.mPtr, port,
|
|
|
|
nick.mPtr, server_pass.mPtr, user_pass.mPtr) == vcmpErrorNullArgument)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Invalid arguments encountered: `{}:{}` `{}` `{}` {}",
|
2021-01-31 17:49:12 +01:00
|
|
|
ip.mPtr, port, nick.mPtr, server_pass.mPtr, user_pass.mPtr);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2018-06-28 20:46:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::GetModuleList() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Send the request
|
|
|
|
_Func->GetPlayerModuleList(m_ID);
|
|
|
|
}
|
|
|
|
|
2016-06-20 07:27:39 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::PlaySound(int32_t sound_id) const
|
2016-06-20 07:27:39 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->PlaySound(_Func->GetPlayerUniqueWorld(m_ID), sound_id, NAN, NAN, NAN);
|
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetDrunkHandling(SQInteger level) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
_Func->SetPlayerDrunkHandling(m_ID, static_cast< uint32_t >(level));
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetDrunkHandling() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->GetPlayerDrunkHandling(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetDrunkVisuals(SQInteger level) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
_Func->SetPlayerDrunkVisuals(m_ID, static_cast< uint8_t >(level));
|
2019-06-01 23:39:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetDrunkVisuals() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->GetPlayerDrunkVisuals(m_ID);
|
|
|
|
}
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-06-24 22:37:58 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpointEx1a(int32_t world, bool sphere, float x, float y, float z,
|
|
|
|
uint8_t r, uint8_t g, uint8_t b, uint8_t a, float radius) const
|
2016-06-24 22:37:58 +02:00
|
|
|
{
|
2016-06-24 23:08:16 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(m_ID, world, sphere, x, y, z, r, g, b, a, radius,
|
2021-03-20 10:51:40 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj()).mObj;
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpointEx1b(int32_t world, bool sphere, float x, float y, float z,
|
|
|
|
uint8_t r, uint8_t g, uint8_t b, uint8_t a, float radius,
|
|
|
|
int32_t header, LightObj & payload) const
|
2016-06-24 22:37:58 +02:00
|
|
|
{
|
2016-06-24 23:08:16 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(m_ID, world, sphere, x, y, z, r, g, b, a,
|
2021-03-20 10:51:40 +01:00
|
|
|
radius, header, payload).mObj;
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpoint1a(int32_t world, bool sphere, const Vector3 & pos,
|
|
|
|
const Color4 & color, float radius) const
|
2016-06-24 22:37:58 +02:00
|
|
|
{
|
2016-06-24 23:08:16 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(m_ID, world, sphere, pos.x, pos.y, pos.z,
|
|
|
|
color.r, color.g, color.b, color.a, radius,
|
2021-03-20 10:51:40 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj()).mObj;
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpoint1b(int32_t world, bool sphere, const Vector3 & pos, const Color4 & color,
|
|
|
|
float radius, int32_t header, LightObj & payload) const
|
2016-06-24 22:37:58 +02:00
|
|
|
{
|
2016-06-24 23:08:16 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-06-24 22:37:58 +02:00
|
|
|
return Core::Get().NewCheckpoint(m_ID, world, sphere, pos.x, pos.y, pos.z,
|
2021-03-20 10:51:40 +01:00
|
|
|
color.r, color.g, color.b, color.a, radius, header, payload).mObj;
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
2017-06-19 03:09:35 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::GetCollideAreas() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2020-03-22 09:00:31 +01:00
|
|
|
return static_cast< bool >(Core::Get().GetPlayer(m_ID).mFlags & ENF_AREA_TRACK);
|
2017-06-19 03:09:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayer::SetCollideAreas(bool toggle) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
if (toggle)
|
|
|
|
{
|
|
|
|
Core::Get().GetPlayer(m_ID).mFlags |= ENF_AREA_TRACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Obtain the actual entity instance
|
|
|
|
auto & inst = Core::Get().GetPlayer(m_ID);
|
|
|
|
// Is this option even enabled?
|
|
|
|
if (!(inst.mFlags & ENF_AREA_TRACK))
|
|
|
|
{
|
|
|
|
return; // Not enabled to begin with
|
|
|
|
}
|
|
|
|
// Disable the option
|
|
|
|
inst.mFlags ^= ENF_AREA_TRACK;
|
|
|
|
// Clear current areas
|
|
|
|
inst.mAreas.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayer::SetAreasCollide(bool toggle) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
if (toggle)
|
|
|
|
{
|
|
|
|
Core::Get().GetPlayer(m_ID).mFlags |= ENF_AREA_TRACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Obtain the actual entity instance
|
|
|
|
auto & inst = Core::Get().GetPlayer(m_ID);
|
|
|
|
// Is this option even enabled?
|
|
|
|
if (!(inst.mFlags & ENF_AREA_TRACK))
|
|
|
|
{
|
|
|
|
return; // Not enabled to begin with
|
|
|
|
}
|
|
|
|
// Disable the option
|
|
|
|
inst.mFlags ^= ENF_AREA_TRACK;
|
|
|
|
// Is the player currently in any areas?
|
|
|
|
if (inst.mAreas.empty())
|
|
|
|
{
|
|
|
|
return; // Nothing to test
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector3 pos;
|
|
|
|
// Obtain the current position of this instance
|
|
|
|
_Func->GetPlayerPosition(m_ID, &pos.x, &pos.y, &pos.z);
|
|
|
|
// Do a final check to see if the player left any area
|
|
|
|
for (auto & ap : inst.mAreas)
|
|
|
|
{
|
|
|
|
// Is the player still in this area?
|
|
|
|
if (!ap.first->TestEx(pos.x, pos.y))
|
|
|
|
{
|
|
|
|
Core::Get().EmitPlayerLeaveArea(m_ID, ap.second); // Emit the script event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Clear current areas
|
|
|
|
inst.mAreas.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetAuthority() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mAuthority;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetAuthority(int32_t level) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
Core::Get().GetPlayer(m_ID).mAuthority = level;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
const String & CPlayer::GetMessagePrefix(uint32_t index) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform a range check on the specified prefix index
|
|
|
|
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Prefix index is out of range: {} >= {}", index, SQMOD_PLAYER_MSG_PREFIXES);
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return mMessagePrefixes[index];
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetMessagePrefix(uint32_t index, StackStrF & prefix)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform a range check on the specified prefix index
|
|
|
|
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Prefix index is out of range: {} >= {}", index, SQMOD_PLAYER_MSG_PREFIXES);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2020-03-22 09:00:31 +01:00
|
|
|
mMessagePrefixes[index].assign(prefix.mPtr,
|
|
|
|
static_cast< size_t >(ClampMin(prefix.mLen, 0)));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-06-08 15:53:16 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetTrackPosition() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetPlayer(m_ID).mTrackPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetTrackPosition(SQInteger num) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Assign the requested information
|
|
|
|
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
|
|
|
}
|
|
|
|
|
2016-07-14 18:52:14 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetTrackPositionEx(SQInteger num, int32_t header, const LightObj & payload) const
|
2016-07-14 18:52:14 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Assign the requested information
|
|
|
|
Core::Get().GetPlayer(m_ID).mTrackPosition = num;
|
|
|
|
Core::Get().GetPlayer(m_ID).mTrackPositionHeader = header;
|
|
|
|
Core::Get().GetPlayer(m_ID).mTrackPositionPayload = payload;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetTrackHeading() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetPlayer(m_ID).mTrackHeading;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetTrackHeading(SQInteger num) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Assign the requested information
|
|
|
|
Core::Get().GetPlayer(m_ID).mTrackHeading = num;
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetLastWeapon() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mLastWeapon;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetLastHealth() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mLastHealth;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetLastArmour() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mLastArmour;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetLastHeading() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mLastHeading;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
const Vector3 & CPlayer::GetLastPosition() const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return Core::Get().GetPlayer(m_ID).mLastPosition;
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2020-05-04 10:58:30 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQFloat CPlayer::GetDistance() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return static_cast< SQFloat >(Core::Get().GetPlayer(m_ID).mDistance);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetDistance(SQFloat distance) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Assign the requested information
|
2021-01-30 07:51:39 +01:00
|
|
|
Core::Get().GetPlayer(m_ID).mDistance = static_cast< double >(distance);
|
2020-05-04 10:58:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::GetTrackDistance() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return static_cast< bool >(Core::Get().GetPlayer(m_ID).mFlags & ENF_DIST_TRACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetTrackDistance(bool toggle) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Assign the requested information
|
|
|
|
if (toggle)
|
|
|
|
{
|
|
|
|
Core::Get().GetPlayer(m_ID).mFlags |= ENF_DIST_TRACK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Core::Get().GetPlayer(m_ID).mFlags ^= ENF_DIST_TRACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StartStream()
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Initialize the stream buffer
|
|
|
|
m_Buffer.Adjust(mBufferInitSize);
|
|
|
|
m_Buffer.Move(0);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::StartStreamEx(uint32_t size)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Initialize the stream buffer
|
|
|
|
m_Buffer.Adjust(size);
|
|
|
|
m_Buffer.Move(0);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-07-23 16:29:23 +02:00
|
|
|
uint32_t CPlayer::GetBufferCursor() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
return m_Buffer.Position();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetBufferCursor(int32_t pos)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2020-03-22 09:00:31 +01:00
|
|
|
m_Buffer.Move(static_cast< Buffer::SzType >(pos));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StreamByte(SQInteger val)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Buffer.Push< uint8_t >(ConvTo< uint8_t >::From(val));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StreamShort(SQInteger val)
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Buffer.Push< int16_t >(ConvTo< int16_t >::From(val));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StreamInt(SQInteger val)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Buffer.Push< int32_t >(ConvTo< int32_t >::From(val));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StreamFloat(SQFloat val)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Buffer.Push< float >(ConvTo< float >::From(val));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::StreamString(StackStrF & val)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Calculate the string length
|
2021-01-30 07:51:39 +01:00
|
|
|
uint16_t length = ConvTo< uint16_t >::From(val.mLen);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Change the size endianness to big endian
|
2021-01-30 07:51:39 +01:00
|
|
|
auto size = static_cast< uint16_t >(((length >> 8u) & 0xFFu) | ((length & 0xFFu) << 8u)); // NOLINT(hicpp-signed-bitwise)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Write the size and then the string contents
|
2021-01-30 07:51:39 +01:00
|
|
|
m_Buffer.Push< uint16_t >(size);
|
2016-11-16 13:49:04 +01:00
|
|
|
m_Buffer.AppendS(val.mPtr, length);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::StreamRawString(StackStrF & val)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Write the the string contents
|
2020-03-22 09:00:31 +01:00
|
|
|
m_Buffer.AppendS(val.mPtr, static_cast< Buffer::SzType >(ClampMin(val.mLen, 0)));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::FlushStream(bool reset)
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Do we even have what to send?
|
|
|
|
if (!m_Buffer)
|
|
|
|
{
|
|
|
|
STHROWF("Cannot send uninitialized stream buffer");
|
|
|
|
}
|
|
|
|
else if (!m_Buffer.Position())
|
|
|
|
{
|
|
|
|
STHROWF("Cannot send empty stream buffer");
|
|
|
|
}
|
|
|
|
// Attempt to send the stream buffer contents
|
|
|
|
const vcmpError result = _Func->SendClientScriptData(m_ID, m_Buffer.Data(), m_Buffer.Position());
|
|
|
|
// Should we reset the buffer cursor?
|
|
|
|
if (reset)
|
|
|
|
{
|
|
|
|
m_Buffer.Move(0);
|
|
|
|
}
|
|
|
|
// Check for errors
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Stream buffer is too big: {}", m_Buffer.Position());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t CPlayer::GetBufferCapacity() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return m_Buffer.Capacity();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-07-07 23:56:54 +02:00
|
|
|
void CPlayer::SendBuffer(const SqBuffer & buffer) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Validate the specified buffer
|
|
|
|
buffer.ValidateDeeper();
|
|
|
|
// Validate the buffer cursor
|
|
|
|
if (!buffer.GetRef()->Position())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
STHROWF("Cannot send empty stream buffer");
|
|
|
|
}
|
|
|
|
// Attempt to send the stream buffer contents
|
|
|
|
const vcmpError result = _Func->SendClientScriptData(m_ID, buffer.GetRef()->Data(),
|
|
|
|
buffer.GetRef()->Position());
|
|
|
|
// Check for errors
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-02-03 16:50:39 +01:00
|
|
|
STHROWF("Stream buffer is too big: {}", buffer.GetRef()->Position());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetPositionX() const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve a temporary float to retrieve the requested component
|
2021-01-30 07:51:39 +01:00
|
|
|
float x = 0.0f, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &x, &dummy, &dummy);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return x;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetPositionY() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve a temporary float to retrieve the requested component
|
2021-01-30 07:51:39 +01:00
|
|
|
float y = 0.0f, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &dummy, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return y;
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
float CPlayer::GetPositionZ() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve a temporary float to retrieve the requested component
|
2021-01-30 07:51:39 +01:00
|
|
|
float z = 0.0f, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the requested component value
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &dummy, &dummy, &z);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Return the requested information
|
2017-08-06 20:15:32 +02:00
|
|
|
return z;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetPositionX(float x) const
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float y, z, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &dummy, &y, &z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, x, y, z);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetPositionY(float y) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float x, z, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &x, &dummy, &z);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, x, y, z);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetPositionZ(float z) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2021-01-30 07:51:39 +01:00
|
|
|
float x, y, dummy;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Retrieve the current values for unchanged components
|
2018-01-30 18:09:54 +01:00
|
|
|
_Func->GetPlayerPosition(m_ID, &x, &y, &dummy);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2020-12-21 11:20:30 +01:00
|
|
|
_Func->SetPlayerPosition(m_ID, x, y, z);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetColorR() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2021-01-30 07:51:39 +01:00
|
|
|
return static_cast< int32_t >((_Func->GetPlayerColour(m_ID) >> 16u) & 0xFFu);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetColorG() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2021-01-30 07:51:39 +01:00
|
|
|
return static_cast< int32_t >((_Func->GetPlayerColour(m_ID) >> 8u) & 0xFFu);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t CPlayer::GetColorB() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
2021-01-30 07:51:39 +01:00
|
|
|
return static_cast< int32_t >(_Func->GetPlayerColour(m_ID) & 0xFFu);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetColorR(int32_t r) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< uint8_t >::From(r) << 16u) | // NOLINT(hicpp-signed-bitwise)
|
2020-03-22 09:00:31 +01:00
|
|
|
(~(0xFFu << 16u) & _Func->GetPlayerColour(m_ID)));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetColorG(int32_t g) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< uint8_t >::From(g) << 8u) | // NOLINT(hicpp-signed-bitwise)
|
2020-03-22 09:00:31 +01:00
|
|
|
(~(0xFFu << 8u) & _Func->GetPlayerColour(m_ID)));
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2021-01-30 07:51:39 +01:00
|
|
|
void CPlayer::SetColorB(int32_t g) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2021-01-30 07:51:39 +01:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< uint8_t >::From(g)) |
|
2020-03-22 09:00:31 +01:00
|
|
|
(~(0xFFu) & _Func->GetPlayerColour(m_ID)));
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2015-11-09 02:29:04 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::Msg(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
// The function needs at least 2 arguments
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message color specified?
|
2015-11-09 02:29:04 +01:00
|
|
|
if (top <= 1)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message color");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message value specified?
|
|
|
|
else if (top <= 2)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2016-06-19 07:13:02 +02:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Propagate the error
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, "Invalid player instance ");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The index where the message should start
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t msgidx = 2;
|
2016-06-19 17:39:12 +02:00
|
|
|
// The message color
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t color = 0;
|
2016-06-19 17:39:12 +02:00
|
|
|
// Attempt to identify and extract the color
|
2016-06-19 18:06:24 +02:00
|
|
|
const SQRESULT res = SqGrabPlayerMessageColor(vm, 2, color, msgidx);
|
2016-06-19 17:39:12 +02:00
|
|
|
// Did we fail to identify a color?
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error!
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, msgidx);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted message string
|
2016-06-19 17:39:12 +02:00
|
|
|
const vcmpError result = _Func->SendClientMessage(player->GetID(), color,
|
2016-05-22 05:20:38 +02:00
|
|
|
"%s%s%s",
|
|
|
|
player->mMessagePrefix.c_str(),
|
|
|
|
val.mPtr,
|
|
|
|
player->mMessagePostfix.c_str());
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Check the result
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Client message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
|
|
|
// This function does not return a value
|
2015-11-09 02:29:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-09 03:32:32 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the index of the message prefix specified?
|
2015-11-09 03:32:32 +01:00
|
|
|
if (top <= 1)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing prefix index");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message value specified?
|
|
|
|
else if (top <= 2)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
2015-11-09 03:32:32 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2015-11-09 03:32:32 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 03:32:32 +01:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 03:32:32 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Invalid player instance");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
|
|
|
// The prefix index
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t index;
|
2016-06-19 17:39:12 +02:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
index = ConvTo< uint32_t >::From(Var< SQInteger >(vm, 2).value);
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2016-06-19 17:39:12 +02:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform a range check on the specified prefix index
|
2016-06-19 17:39:12 +02:00
|
|
|
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Prefix index is out of range: %u >= %u",
|
|
|
|
index, SQMOD_PLAYER_MSG_PREFIXES);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 3);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 03:32:32 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2020-03-22 09:00:31 +01:00
|
|
|
vcmpError result;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted message string
|
|
|
|
if (player->mLimitPrefixPostfixMessage)
|
|
|
|
{
|
|
|
|
result = _Func->SendClientMessage(player->GetID(), player->mMessageColor, "%s%s",
|
|
|
|
player->mMessagePrefixes[index].c_str(), val.mPtr);
|
2015-11-09 03:32:32 +01:00
|
|
|
}
|
|
|
|
else
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
result = _Func->SendClientMessage(player->GetID(), player->mMessageColor, "%s%s%s%s",
|
|
|
|
player->mMessagePrefix.c_str(),
|
|
|
|
player->mMessagePrefixes[index].c_str(), val.mPtr,
|
|
|
|
player->mMessagePostfix.c_str());
|
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Check the result
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Client message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
|
|
|
// This function does not return a value
|
2015-11-09 03:32:32 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-09 02:29:04 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-06-19 17:39:12 +02:00
|
|
|
// Was the index of the message prefix specified?
|
|
|
|
if (top <= 1)
|
|
|
|
{
|
|
|
|
return sq_throwerror(vm, "Missing prefix index");
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message color specified?
|
2016-06-19 17:39:12 +02:00
|
|
|
else if (top <= 2)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message color");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message value specified?
|
2016-06-19 17:39:12 +02:00
|
|
|
else if (top <= 3)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Invalid player instance");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
|
|
|
// The prefix index
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t index;
|
2016-06-19 17:39:12 +02:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
index = ConvTo< uint32_t >::From(Var< SQInteger >(vm, 2).value);
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2016-06-19 17:39:12 +02:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Perform a range check on the specified prefix index
|
|
|
|
if (index >= SQMOD_PLAYER_MSG_PREFIXES)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Prefix index is out of range: %u >= %u",
|
|
|
|
index, SQMOD_PLAYER_MSG_PREFIXES);
|
2016-06-19 17:39:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The index where the message should start
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t msgidx = 3;
|
2016-06-19 17:39:12 +02:00
|
|
|
// The message color
|
2021-01-30 07:51:39 +01:00
|
|
|
uint32_t color = 0;
|
2016-06-19 17:39:12 +02:00
|
|
|
// Attempt to identify and extract the color
|
2016-06-19 18:06:24 +02:00
|
|
|
const SQRESULT res = SqGrabPlayerMessageColor(vm, 3, color, msgidx);
|
2016-06-19 17:39:12 +02:00
|
|
|
// Did we fail to identify a color?
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error!
|
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, msgidx);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2020-03-22 09:00:31 +01:00
|
|
|
vcmpError result;
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted message string
|
2016-06-19 17:39:12 +02:00
|
|
|
if (player->mLimitPrefixPostfixMessage)
|
|
|
|
{
|
|
|
|
result = _Func->SendClientMessage(player->GetID(), color, "%s%s",
|
|
|
|
player->mMessagePrefixes[index].c_str(), val.mPtr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = _Func->SendClientMessage(player->GetID(), color, "%s%s%s%s",
|
|
|
|
player->mMessagePrefix.c_str(),
|
|
|
|
player->mMessagePrefixes[index].c_str(), val.mPtr,
|
|
|
|
player->mMessagePostfix.c_str());
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Check the result
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Client message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// This function does not return a value
|
2015-11-09 02:29:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::Message(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the message value specified?
|
2015-11-09 02:29:04 +01:00
|
|
|
if (top <= 1)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing message value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Invalid player instance");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 2);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted message string
|
|
|
|
const vcmpError result = _Func->SendClientMessage(player->GetID(), player->mMessageColor,
|
|
|
|
"%s%s%s",
|
|
|
|
player->mMessagePrefix.c_str(),
|
|
|
|
val.mPtr,
|
|
|
|
player->mMessagePostfix.c_str());
|
|
|
|
// Check the result
|
|
|
|
if (result == vcmpErrorTooLargeInput)
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Client message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// This function does not return a value
|
2015-11-09 02:29:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::Announce(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the announcement value specified?
|
2015-11-09 02:29:04 +01:00
|
|
|
if (top <= 1)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing announcement value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-07-09 13:18:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Invalid player instance");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 2);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted announcement string
|
|
|
|
const vcmpError result = _Func->SendGameMessage(player->GetID(), player->mAnnounceStyle,
|
|
|
|
"%s%s%s",
|
|
|
|
player->mAnnouncePrefix.c_str(),
|
|
|
|
val.mPtr,
|
|
|
|
player->mAnnouncePostfix.c_str());
|
|
|
|
// Validate the result
|
|
|
|
if (result == vcmpErrorArgumentOutOfBounds)
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid announcement style %d [%s]",
|
|
|
|
player->mAnnounceStyle, player->GetTag().c_str());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
else if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Game message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// This function does not return a value
|
2015-11-09 02:29:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
|
|
|
|
{
|
2020-03-22 09:00:31 +01:00
|
|
|
const auto top = sq_gettop(vm);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the announcement style specified?
|
2015-11-09 02:29:04 +01:00
|
|
|
if (top <= 1)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing announcement style");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Was the announcement value specified?
|
|
|
|
else if (top <= 2)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Missing announcement value");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// The player instance
|
2021-01-30 07:51:39 +01:00
|
|
|
CPlayer * player;
|
2016-03-10 04:57:13 +01:00
|
|
|
// The announcement style
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t style;
|
2016-03-10 04:57:13 +01:00
|
|
|
// style to extract the argument values
|
|
|
|
try
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
player = Var< CPlayer * >(vm, 1).value;
|
2021-01-30 07:51:39 +01:00
|
|
|
style = Var< int32_t >(vm, 2).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2021-01-30 07:51:39 +01:00
|
|
|
catch (const std::exception & e)
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-07-09 16:14:09 +02:00
|
|
|
return sq_throwerror(vm, e.what());
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player instance?
|
|
|
|
if (!player)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, "Invalid player instance");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Do we have a valid player identifier?
|
|
|
|
else if (!player->IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid player reference [%s]", player->GetTag().c_str());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to generate the string value
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 3);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2015-11-09 02:29:04 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
return val.mRes; // Propagate the error!
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// Send the resulted announcement string
|
|
|
|
const vcmpError result = _Func->SendGameMessage(player->GetID(), style, "%s%s%s",
|
|
|
|
player->mAnnouncePrefix.c_str(),
|
|
|
|
val.mPtr,
|
|
|
|
player->mAnnouncePostfix.c_str());
|
|
|
|
// Validate the result
|
|
|
|
if (result == vcmpErrorArgumentOutOfBounds)
|
2016-03-10 04:57:13 +01:00
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Invalid announcement style %d [%s]",
|
|
|
|
style, player->GetTag().c_str());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
else if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
return sq_throwerrorf(vm, "Game message too big [%s]", player->GetTag().c_str());
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2016-06-19 17:39:12 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// This function does not return a value
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-06-21 15:15:25 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 17:14:58 +02:00
|
|
|
SQInteger Player_FindAuto(HSQUIRRELVM vm)
|
2016-06-21 15:15:25 +02:00
|
|
|
{
|
2017-08-06 16:01:59 +02:00
|
|
|
// See if a search token was specified
|
|
|
|
if (sq_gettop(vm) <= 1)
|
2016-06-21 15:15:25 +02:00
|
|
|
{
|
2017-08-06 16:01:59 +02:00
|
|
|
return sq_throwerror(vm, _SC("Please specify a token with which to identify the player (id/name)"));
|
|
|
|
}
|
|
|
|
// Identify the token type.
|
|
|
|
switch (sq_gettype(vm, 2))
|
|
|
|
{
|
|
|
|
case OT_INTEGER: {
|
|
|
|
SQInteger id;
|
|
|
|
// Attempt to retrieve the given id
|
|
|
|
const SQRESULT res = sq_getinteger(vm, 2, &id);
|
|
|
|
// Validate the given identifier
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error
|
|
|
|
}
|
|
|
|
// Check identifier range
|
|
|
|
else if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
sq_pushnull(vm); // Default to null
|
|
|
|
}
|
|
|
|
// Finally, attempt to push the return value
|
|
|
|
else
|
|
|
|
{
|
2021-01-30 07:51:39 +01:00
|
|
|
sq_pushobject(vm, Core::Get().GetPlayer(static_cast< int32_t >(id)).mObj.mObj);
|
2017-08-06 16:01:59 +02:00
|
|
|
}
|
2016-06-21 15:15:25 +02:00
|
|
|
} break;
|
2017-08-06 16:01:59 +02:00
|
|
|
case OT_FLOAT: {
|
|
|
|
|
|
|
|
SQFloat fid;
|
|
|
|
// Attempt to retrieve the given id
|
|
|
|
const SQRESULT res = sq_getfloat(vm, 2, &fid);
|
|
|
|
// Validate the given identifier
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error
|
|
|
|
}
|
|
|
|
// Convert the float value to an integer
|
2021-01-30 07:51:39 +01:00
|
|
|
const auto id = static_cast< int32_t >(std::lround(static_cast< float >(fid)));
|
2017-08-06 16:01:59 +02:00
|
|
|
// Check identifier range
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
sq_pushnull(vm); // Default to null
|
|
|
|
}
|
|
|
|
// Finally, attempt to push the return value
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sq_pushobject(vm, Core::Get().GetPlayer(id).mObj.mObj);
|
|
|
|
}
|
2016-06-21 15:15:25 +02:00
|
|
|
} break;
|
|
|
|
case OT_STRING:
|
2017-08-06 16:01:59 +02:00
|
|
|
default: {
|
|
|
|
// Attempt to convert the obtained value to a string
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 2);
|
2017-08-06 16:01:59 +02:00
|
|
|
// Did the conversion failed?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2017-08-06 16:01:59 +02:00
|
|
|
{
|
|
|
|
return val.mRes; // Propagate the error
|
|
|
|
}
|
|
|
|
else if (val.mLen <= 0)
|
|
|
|
{
|
|
|
|
// Default to null
|
|
|
|
sq_pushnull(vm);
|
|
|
|
// Stop here!
|
|
|
|
break;
|
|
|
|
}
|
2016-06-21 15:15:25 +02:00
|
|
|
// Attempt to locate the player with this name
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t id = _Func->GetPlayerIdFromName(val.mPtr);
|
2016-06-21 15:15:25 +02:00
|
|
|
// Was there a player with this name?
|
2017-08-06 16:01:59 +02:00
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
sq_pushnull(vm); // Default to null
|
|
|
|
}
|
|
|
|
// Finally, attempt to push the return value
|
|
|
|
else
|
2016-06-21 15:15:25 +02:00
|
|
|
{
|
2017-08-06 16:01:59 +02:00
|
|
|
sq_pushobject(vm, Core::Get().GetPlayer(id).mObj.mObj);
|
2016-06-21 15:15:25 +02:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
2017-08-06 16:01:59 +02:00
|
|
|
// There should be a value on the stack with the found player
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-08-06 17:14:58 +02:00
|
|
|
SQInteger Player_ExistsAuto(HSQUIRRELVM vm)
|
2017-08-06 16:01:59 +02:00
|
|
|
{
|
|
|
|
// See if a search token was specified
|
|
|
|
if (sq_gettop(vm) <= 1)
|
|
|
|
{
|
|
|
|
return sq_throwerror(vm, _SC("Please specify a token with which to identify the player (id/name)"));
|
|
|
|
}
|
|
|
|
// Identify the token type.
|
|
|
|
switch (sq_gettype(vm, 2))
|
|
|
|
{
|
|
|
|
case OT_INTEGER: {
|
|
|
|
SQInteger id;
|
|
|
|
// Attempt to retrieve the given id
|
|
|
|
const SQRESULT res = sq_getinteger(vm, 2, &id);
|
|
|
|
// Validate the given identifier
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error
|
|
|
|
}
|
|
|
|
// Check identifier range and the entity instance
|
2021-01-30 07:51:39 +01:00
|
|
|
else if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(static_cast< int32_t >(id)).mID))
|
2017-08-06 16:01:59 +02:00
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQFalse);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQTrue);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case OT_FLOAT: {
|
|
|
|
|
|
|
|
SQFloat fid;
|
|
|
|
// Attempt to retrieve the given id
|
|
|
|
const SQRESULT res = sq_getfloat(vm, 2, &fid);
|
|
|
|
// Validate the given identifier
|
|
|
|
if (SQ_FAILED(res))
|
|
|
|
{
|
|
|
|
return res; // Propagate the error
|
|
|
|
}
|
|
|
|
// Convert the float value to an integer
|
2021-01-30 07:51:39 +01:00
|
|
|
const auto id = static_cast< int32_t >(std::lround(static_cast< float >(fid)));
|
2017-08-06 16:01:59 +02:00
|
|
|
// Check identifier range and the entity instance
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(id).mID))
|
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQFalse);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQTrue);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case OT_STRING:
|
|
|
|
default: {
|
|
|
|
// Attempt to convert the obtained value to a string
|
2018-07-29 23:58:27 +02:00
|
|
|
StackStrF val(vm, 2);
|
2017-08-06 16:01:59 +02:00
|
|
|
// Did the conversion failed?
|
2018-07-29 23:58:27 +02:00
|
|
|
if (SQ_FAILED(val.Proc(true)))
|
2017-08-06 16:01:59 +02:00
|
|
|
{
|
|
|
|
return val.mRes; // Propagate the error
|
|
|
|
}
|
|
|
|
else if (val.mLen <= 0)
|
|
|
|
{
|
|
|
|
// Default to false
|
|
|
|
sq_pushbool(vm, SQFalse);
|
|
|
|
// Stop here!
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Attempt to locate the player with this name
|
2021-01-30 07:51:39 +01:00
|
|
|
int32_t id = _Func->GetPlayerIdFromName(val.mPtr);
|
2017-08-06 16:01:59 +02:00
|
|
|
// Check identifier range and the entity instance
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL) || INVALID_ENTITY(Core::Get().GetPlayer(id).mID))
|
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQFalse);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sq_pushbool(vm, SQTrue);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
// There should be a value on the stack with the found player
|
|
|
|
return 1;
|
2016-06-21 15:15:25 +02:00
|
|
|
}
|
|
|
|
|
2015-10-29 21:11:30 +01:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CPlayer(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-11-15 20:16:24 +01:00
|
|
|
RootTable(vm).Bind(Typename::Str,
|
|
|
|
Class< CPlayer, NoConstructor< CPlayer > >(vm, Typename::Str)
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-11-15 20:16:24 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &Typename::Fn)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_tostring"), &CPlayer::ToString)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Values
|
2016-03-10 04:57:13 +01:00
|
|
|
.SetStaticValue(_SC("MaxID"), CPlayer::Max)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Member Variables
|
|
|
|
.Var(_SC("BufferInitSize"), &CPlayer::mBufferInitSize)
|
|
|
|
.Var(_SC("MessageColor"), &CPlayer::mMessageColor)
|
|
|
|
.Var(_SC("AnnounceStyle"), &CPlayer::mAnnounceStyle)
|
|
|
|
.Var(_SC("DefaultAmmo"), &CPlayer::mDefaultAmmo)
|
|
|
|
.Var(_SC("MessagePrefix"), &CPlayer::mMessagePrefix)
|
|
|
|
.Var(_SC("MessagePostfix"), &CPlayer::mMessagePostfix)
|
|
|
|
.Var(_SC("AnnouncePrefix"), &CPlayer::mAnnouncePrefix)
|
|
|
|
.Var(_SC("AnnouncePostfix"), &CPlayer::mAnnouncePostfix)
|
|
|
|
.Var(_SC("LimitPrefixPostfixMessage"), &CPlayer::mLimitPrefixPostfixMessage)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Core Properties
|
2017-02-21 20:24:59 +01:00
|
|
|
.Prop(_SC("On"), &CPlayer::GetEvents)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("ID"), &CPlayer::GetID)
|
|
|
|
.Prop(_SC("Tag"), &CPlayer::GetTag, &CPlayer::SetTag)
|
|
|
|
.Prop(_SC("Data"), &CPlayer::GetData, &CPlayer::SetData)
|
|
|
|
.Prop(_SC("Active"), &CPlayer::IsActive)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Core Methods
|
2016-11-16 13:49:04 +01:00
|
|
|
.FmtFunc(_SC("SetTag"), &CPlayer::ApplyTag)
|
2016-07-26 23:13:50 +02:00
|
|
|
.Func(_SC("CustomEvent"), &CPlayer::CustomEvent)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Properties
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Connected"), &CPlayer::IsConnected)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Admin"), &CPlayer::GetAdmin, &CPlayer::SetAdmin)
|
|
|
|
.Prop(_SC("IP"), &CPlayer::GetIP)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("UID"), &CPlayer::GetUID)
|
|
|
|
.Prop(_SC("UID2"), &CPlayer::GetUID2)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Key"), &CPlayer::GetKey)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Name"), &CPlayer::GetName, &CPlayer::SetName)
|
|
|
|
.Prop(_SC("State"), &CPlayer::GetState)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("World"), &CPlayer::GetWorld, &CPlayer::SetWorld)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("SecWorld"), &CPlayer::GetSecondaryWorld, &CPlayer::SetSecondaryWorld)
|
|
|
|
.Prop(_SC("SecondaryWorld"), &CPlayer::GetSecondaryWorld, &CPlayer::SetSecondaryWorld)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("UniqueWorld"), &CPlayer::GetUniqueWorld)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Class"), &CPlayer::GetClass)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Team"), &CPlayer::GetTeam, &CPlayer::SetTeam)
|
|
|
|
.Prop(_SC("Skin"), &CPlayer::GetSkin, &CPlayer::SetSkin)
|
|
|
|
.Prop(_SC("Color"), &CPlayer::GetColor, &CPlayer::SetColor)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Colour"), &CPlayer::GetColor, &CPlayer::SetColor)
|
|
|
|
.Prop(_SC("Spawned"), &CPlayer::IsSpawned)
|
|
|
|
.Prop(_SC("Typing"), &CPlayer::IsTyping)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Money"), &CPlayer::GetMoney, &CPlayer::SetMoney)
|
|
|
|
.Prop(_SC("Score"), &CPlayer::GetScore, &CPlayer::SetScore)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("WantedLevel"), &CPlayer::GetWantedLevel, &CPlayer::SetWantedLevel)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Ping"), &CPlayer::GetPing)
|
|
|
|
.Prop(_SC("FPS"), &CPlayer::GetFPS)
|
|
|
|
.Prop(_SC("Health"), &CPlayer::GetHealth, &CPlayer::SetHealth)
|
2016-03-10 04:57:13 +01:00
|
|
|
.Prop(_SC("Armor"), &CPlayer::GetArmor, &CPlayer::SetArmor)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Armour"), &CPlayer::GetArmor, &CPlayer::SetArmor)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Immunity"), &CPlayer::GetImmunity, &CPlayer::SetImmunity)
|
|
|
|
.Prop(_SC("Pos"), &CPlayer::GetPosition, &CPlayer::SetPosition)
|
|
|
|
.Prop(_SC("Position"), &CPlayer::GetPosition, &CPlayer::SetPosition)
|
|
|
|
.Prop(_SC("Speed"), &CPlayer::GetSpeed, &CPlayer::SetSpeed)
|
|
|
|
.Prop(_SC("Angle"), &CPlayer::GetHeading, &CPlayer::SetHeading)
|
|
|
|
.Prop(_SC("Heading"), &CPlayer::GetHeading, &CPlayer::SetHeading)
|
|
|
|
.Prop(_SC("Alpha"), &CPlayer::GetAlpha, &CPlayer::SetAlpha)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("AimPos"), &CPlayer::GetAimPosition)
|
|
|
|
.Prop(_SC("AimPosition"), &CPlayer::GetAimPosition)
|
|
|
|
.Prop(_SC("AimDir"), &CPlayer::GetAimDirection)
|
|
|
|
.Prop(_SC("AimDirection"), &CPlayer::GetAimDirection)
|
|
|
|
.Prop(_SC("Burning"), &CPlayer::IsBurning)
|
|
|
|
.Prop(_SC("Crouched"), &CPlayer::IsCrouched)
|
|
|
|
.Prop(_SC("Action"), &CPlayer::GetAction)
|
|
|
|
.Prop(_SC("GameKeys"), &CPlayer::GetGameKeys)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("VehicleStatus"), &CPlayer::GetVehicleStatus)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("VehicleSlot"), &CPlayer::GetVehicleSlot)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Vehicle"), &CPlayer::GetVehicle)
|
|
|
|
.Prop(_SC("VehicleID"), &CPlayer::GetVehicleID)
|
|
|
|
.Prop(_SC("Weapon"), &CPlayer::GetWeapon, &CPlayer::SetWeapon)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("Ammo"), &CPlayer::GetAmmo)
|
|
|
|
.Prop(_SC("WeaponSlot"), &CPlayer::GetWeaponSlot, &CPlayer::SetWeaponSlot)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("CameraLocked"), &CPlayer::IsCameraLocked)
|
|
|
|
.Prop(_SC("TouchedVehicle"), &CPlayer::StandingOnVehicle)
|
|
|
|
.Prop(_SC("TouchedObject"), &CPlayer::StandingOnObject)
|
|
|
|
.Prop(_SC("Away"), &CPlayer::IsAway)
|
|
|
|
.Prop(_SC("Spec"), &CPlayer::GetSpectator, &CPlayer::SetSpectator)
|
2017-08-06 14:14:45 +02:00
|
|
|
.Prop(_SC("SpecID"), &CPlayer::GetSpectatorID, &CPlayer::SetSpectatorID)
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
.Prop(_SC("DrunkHandling"), &CPlayer::GetDrunkHandling, &CPlayer::SetDrunkHandling)
|
|
|
|
.Prop(_SC("DrunkVisuals"), &CPlayer::GetDrunkVisuals, &CPlayer::SetDrunkVisuals)
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2017-06-19 03:09:35 +02:00
|
|
|
.Prop(_SC("CollideAreas"), &CPlayer::GetCollideAreas, &CPlayer::SetCollideAreas)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
2016-06-08 15:53:16 +02:00
|
|
|
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
2016-07-14 18:52:14 +02:00
|
|
|
.Prop(_SC("TrackHeading"), &CPlayer::GetTrackHeading, &CPlayer::SetTrackHeading)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("LastWeapon"), &CPlayer::GetLastWeapon)
|
|
|
|
.Prop(_SC("LastHealth"), &CPlayer::GetLastHealth)
|
2016-06-13 23:50:20 +02:00
|
|
|
.Prop(_SC("LastArmor"), &CPlayer::GetLastArmour)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("LastArmour"), &CPlayer::GetLastArmour)
|
|
|
|
.Prop(_SC("LastHeading"), &CPlayer::GetLastHeading)
|
|
|
|
.Prop(_SC("LastPosition"), &CPlayer::GetLastPosition)
|
2020-05-04 10:58:30 +02:00
|
|
|
.Prop(_SC("Distance"), &CPlayer::GetDistance, &CPlayer::SetDistance)
|
|
|
|
.Prop(_SC("TrackDistance"), &CPlayer::GetTrackDistance, &CPlayer::SetTrackDistance)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Prop(_SC("BufferCursor"), &CPlayer::GetBufferCursor, &CPlayer::SetBufferCursor)
|
|
|
|
.Prop(_SC("BufferCapacity"), &CPlayer::GetBufferCapacity)
|
|
|
|
.Prop(_SC("PosX"), &CPlayer::GetPositionX, &CPlayer::SetPositionX)
|
|
|
|
.Prop(_SC("PosY"), &CPlayer::GetPositionY, &CPlayer::SetPositionY)
|
|
|
|
.Prop(_SC("PosZ"), &CPlayer::GetPositionZ, &CPlayer::SetPositionZ)
|
|
|
|
.Prop(_SC("Red"), &CPlayer::GetColorR, &CPlayer::SetColorR)
|
|
|
|
.Prop(_SC("Green"), &CPlayer::GetColorG, &CPlayer::SetColorG)
|
|
|
|
.Prop(_SC("Blue"), &CPlayer::GetColorB, &CPlayer::SetColorB)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("StreamedFor"), &CPlayer::IsStreamedFor)
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
.Func(_SC("Kill"), &CPlayer::Kill)
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Kick"), &CPlayer::Kick)
|
|
|
|
.Func(_SC("Ban"), &CPlayer::Ban)
|
2016-08-17 12:48:29 +02:00
|
|
|
.Func(_SC("KickBecause"), &CPlayer::KickBecause)
|
|
|
|
.Func(_SC("BanBecause"), &CPlayer::BanBecause)
|
2016-11-16 13:49:04 +01:00
|
|
|
.FmtFunc(_SC("SetName"), &CPlayer::SetName)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("GetOption"), &CPlayer::GetOption)
|
|
|
|
.Func(_SC("SetOption"), &CPlayer::SetOption)
|
|
|
|
.Func(_SC("SetOptionEx"), &CPlayer::SetOptionEx)
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-08-13 17:34:09 +02:00
|
|
|
.Func(_SC("GetNetworkStatisticsF"), &CPlayer::GetNetworkStatisticsF)
|
|
|
|
.Func(_SC("GetNetworkStatisticsI"), &CPlayer::GetNetworkStatisticsI)
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("WorldCompatible"), &CPlayer::IsWorldCompatible)
|
|
|
|
.Func(_SC("SetColor"), &CPlayer::SetColorEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("SetColour"), &CPlayer::SetColorEx)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Spawn"), &CPlayer::ForceSpawn)
|
|
|
|
.Func(_SC("Select"), &CPlayer::ForceSelect)
|
|
|
|
.Func(_SC("GiveMoney"), &CPlayer::GiveMoney)
|
|
|
|
.Func(_SC("SetPos"), &CPlayer::SetPositionEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("SetPosition"), &CPlayer::SetPositionEx)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("SetSpeed"), &CPlayer::SetSpeedEx)
|
2016-06-20 07:08:33 +02:00
|
|
|
.Func(_SC("SetAlpha"), &CPlayer::SetAlphaEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("Disembark"), &CPlayer::Disembark)
|
|
|
|
.Func(_SC("SetWeapon"), &CPlayer::SetWeaponEx)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("GiveWeapon"), &CPlayer::GiveWeapon)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("WeaponAtSlot"), &CPlayer::GetWeaponAtSlot)
|
|
|
|
.Func(_SC("AmmoAtSlot"), &CPlayer::GetAmmoAtSlot)
|
|
|
|
.Func(_SC("RemoveWeapon"), &CPlayer::RemoveWeapon)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("StripWeapons"), &CPlayer::StripWeapons)
|
|
|
|
.Func(_SC("RestoreCamera"), &CPlayer::RestoreCamera)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("Spectating"), &CPlayer::GetSpectator)
|
2017-08-06 17:24:42 +02:00
|
|
|
.Func(_SC("Unspectate"), &CPlayer::Unspectate)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Spectate"), &CPlayer::SetSpectator)
|
2020-03-20 19:37:17 +01:00
|
|
|
#if SQMOD_SDK_LEAST(2, 1)
|
2019-06-01 23:39:06 +02:00
|
|
|
.Func(_SC("SetPlayer3DArrow"), &CPlayer::SetPlayer3DArrow)
|
|
|
|
.Func(_SC("GetPlayer3DArrow"), &CPlayer::GetPlayer3DArrow)
|
|
|
|
.Func(_SC("SetPlayer3DArrowID"), &CPlayer::SetPlayer3DArrowID)
|
|
|
|
.Func(_SC("GetPlayer3DArrowID"), &CPlayer::GetPlayer3DArrowID)
|
|
|
|
.Func(_SC("InterpolateCameraLookAt"), &CPlayer::InterpolateCameraLookAt)
|
|
|
|
.Func(_SC("InterpolateCameraLookAtEx"), &CPlayer::InterpolateCameraLookAtEx)
|
2020-03-20 19:37:17 +01:00
|
|
|
#endif
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Redirect"), &CPlayer::Redirect)
|
2018-06-28 20:46:06 +02:00
|
|
|
.Func(_SC("GetModuleList"), &CPlayer::GetModuleList)
|
2016-06-20 07:27:39 +02:00
|
|
|
.Func(_SC("PlaySound"), &CPlayer::PlaySound)
|
2017-06-19 03:09:35 +02:00
|
|
|
.Func(_SC("AreasCollide"), &CPlayer::SetAreasCollide)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix)
|
2016-11-16 13:49:04 +01:00
|
|
|
.FmtFunc(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix)
|
2016-07-14 18:52:14 +02:00
|
|
|
.Func(_SC("SetTrackPosition"), &CPlayer::SetTrackPositionEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("StreamByte"), &CPlayer::StreamByte)
|
|
|
|
.Func(_SC("StreamShort"), &CPlayer::StreamShort)
|
|
|
|
.Func(_SC("StreamInt"), &CPlayer::StreamInt)
|
|
|
|
.Func(_SC("StreamFloat"), &CPlayer::StreamFloat)
|
2016-11-16 13:49:04 +01:00
|
|
|
.FmtFunc(_SC("StreamString"), &CPlayer::StreamString)
|
|
|
|
.FmtFunc(_SC("StreamRawString"), &CPlayer::StreamRawString)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("FlushStream"), &CPlayer::FlushStream)
|
|
|
|
.Func(_SC("SendBuffer"), &CPlayer::SendBuffer)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Overloads
|
2021-01-30 07:51:39 +01:00
|
|
|
.Overload(_SC("AddSpeed"), &CPlayer::AddSpeed)
|
|
|
|
.Overload(_SC("AddSpeed"), &CPlayer::AddSpeedEx)
|
|
|
|
.Overload(_SC("Embark"), &CPlayer::Embark)
|
|
|
|
.Overload(_SC("Embark"), &CPlayer::EmbarkEx)
|
|
|
|
.Overload(_SC("CameraPosition"), &CPlayer::SetCameraPosition)
|
|
|
|
.Overload(_SC("CameraPosition"), &CPlayer::SetCameraPositionEx)
|
|
|
|
.Overload(_SC("StartStream"), &CPlayer::StartStream)
|
|
|
|
.Overload(_SC("StartStream"), &CPlayer::StartStreamEx)
|
|
|
|
.Overload(_SC("SetAnimation"), &CPlayer::SetAnimation)
|
|
|
|
.Overload(_SC("SetAnimation"), &CPlayer::SetAnimationEx)
|
|
|
|
.Overload(_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx1a)
|
|
|
|
.Overload(_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx1b)
|
|
|
|
.Overload(_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint1a)
|
|
|
|
.Overload(_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint1b)
|
2016-06-21 15:15:25 +02:00
|
|
|
// Static Functions
|
2017-08-06 16:01:59 +02:00
|
|
|
.SquirrelFunc(_SC("Find"), &Player_FindAuto)
|
|
|
|
.SquirrelFunc(_SC("Exists"), &Player_ExistsAuto)
|
2016-05-22 05:20:38 +02:00
|
|
|
// Raw Squirrel Methods
|
|
|
|
.SquirrelFunc(_SC("Msg"), &CPlayer::Msg)
|
|
|
|
.SquirrelFunc(_SC("MsgP"), &CPlayer::MsgP)
|
|
|
|
.SquirrelFunc(_SC("MsgEx"), &CPlayer::MsgEx)
|
|
|
|
.SquirrelFunc(_SC("Message"), &CPlayer::Message)
|
|
|
|
.SquirrelFunc(_SC("Announce"), &CPlayer::Announce)
|
|
|
|
.SquirrelFunc(_SC("AnnounceEx"), &CPlayer::AnnounceEx)
|
|
|
|
.SquirrelFunc(_SC("Text"), &CPlayer::Announce)
|
|
|
|
.SquirrelFunc(_SC("TextEx"), &CPlayer::AnnounceEx)
|
2016-08-07 00:54:33 +02:00
|
|
|
.SquirrelFunc(_SC("NullInst"), &CPlayer::SqGetNull)
|
2016-11-16 23:23:59 +01:00
|
|
|
.SquirrelFunc(_SC("MakeTask"), &Tasks::MakeTask< CPlayer, ENT_PLAYER >)
|
|
|
|
.SquirrelFunc(_SC("DropTask"), &Tasks::DropTask< CPlayer, ENT_PLAYER >)
|
|
|
|
.SquirrelFunc(_SC("DoesTask"), &Tasks::DoesTask< CPlayer, ENT_PLAYER >)
|
2016-11-17 16:04:21 +01:00
|
|
|
.SquirrelFunc(_SC("FindTask"), &Tasks::FindTask< CPlayer, ENT_PLAYER >)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|