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"
|
2016-07-07 23:56:54 +02:00
|
|
|
#include "Library/Utils/Buffer.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Core.hpp"
|
2018-07-29 11:25:44 +02:00
|
|
|
#include "Misc/Areas.hpp"
|
|
|
|
#include "Misc/Tasks.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <cstring>
|
|
|
|
|
2015-11-09 02:29:04 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include <sqstdstring.h>
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2016-06-19 18:06:24 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
extern SQRESULT SqGrabPlayerMessageColor(HSQUIRRELVM vm, Int32 idx, Uint32 & color, Int32 & msgidx);
|
|
|
|
|
2016-11-15 20:16:24 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQMODE_DECL_TYPENAME(Typename, _SC("SqPlayer"))
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const Int32 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)
|
|
|
|
{
|
|
|
|
sq_pushobject(vm, Core::Get().GetNullPlayer().GetObject());
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CPlayer::CPlayer(Int32 id)
|
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_PLAYER_POOL))
|
2016-05-22 05:20:38 +02:00
|
|
|
, m_Tag(ToStrF("%d", id)), m_Data(), m_Buffer(256), m_CircularLocks(0)
|
|
|
|
, mBufferInitSize(256)
|
|
|
|
, mMessageColor(0x6599FFFF)
|
|
|
|
, mAnnounceStyle(1)
|
|
|
|
, mDefaultAmmo(0)
|
|
|
|
, mMessagePrefix(_SC(""))
|
|
|
|
, mMessagePostfix(_SC(""))
|
|
|
|
, mAnnouncePrefix(_SC(""))
|
|
|
|
, mAnnouncePostfix(_SC(""))
|
|
|
|
, mMessagePrefixes()
|
|
|
|
, mLimitPrefixPostfixMessage(true)
|
|
|
|
{
|
|
|
|
// Reset message prefixes
|
|
|
|
for (unsigned n = 0; n < SQMOD_PLAYER_MSG_PREFIXES; ++n)
|
|
|
|
{
|
|
|
|
mMessagePrefixes[n].assign(_SC(""));
|
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CPlayer::~CPlayer()
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01: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)
|
|
|
|
{
|
|
|
|
m_Tag.assign(tag.mPtr, tag.mLen);
|
|
|
|
}
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::CustomEvent(Int32 header, LightObj & payload) const
|
2016-07-26 23:13:50 +02:00
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perfrom the requested action
|
|
|
|
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 property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerAdmin(m_ID, toggle);
|
2016-08-17 14:40:48 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CSStr CPlayer::GetUID() const
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CSStr CPlayer::GetUID2() const
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::KickBecause(Int32 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::BanBecause(Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Uint32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
CSStr 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
|
|
|
{
|
|
|
|
STHROWF("The specified name is invalid");
|
|
|
|
}
|
2016-08-27 03:03:24 +02:00
|
|
|
else if (ret == vcmpErrorTooLargeInput)
|
|
|
|
{
|
|
|
|
STHROWF("The specified name is too large");
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Int32 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Int32 CPlayer::GetOption(Int32 option_id) const
|
|
|
|
{
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: %d", option_id);
|
|
|
|
}
|
|
|
|
// Return the requested value
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetOption(Int32 option_id, bool toggle)
|
|
|
|
{
|
2017-02-21 20:24:59 +01:00
|
|
|
SetOptionEx(option_id, toggle, 0, NullLightObj());
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::SetOptionEx(Int32 option_id, bool toggle, Int32 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 property unwind from a recursive call
|
|
|
|
else if (_Func->SetPlayerOption(m_ID,
|
|
|
|
static_cast< vcmpPlayerOption >(option_id), toggle) == vcmpErrorArgumentOutOfBounds)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: %d", option_id);
|
|
|
|
}
|
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
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2019-08-13 17:29:09 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-08-13 17:34:09 +02:00
|
|
|
SQFloat CPlayer::GetNetworkStatisticsF(Int32 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetNetworkStatisticsI(Int32 option_id) const
|
|
|
|
{
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:45:44 +02:00
|
|
|
void CPlayer::SetWorld(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerWorld(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerWorld(m_ID, world);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:45:44 +02:00
|
|
|
void CPlayer::SetSecondaryWorld(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerSecondaryWorld(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == world)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerSecondaryWorld(m_ID, world);
|
2016-08-17 14:45:44 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CPlayer::IsWorldCompatible(Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:49:08 +02:00
|
|
|
void CPlayer::SetTeam(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerTeam(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == team)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
else if (_Func->SetPlayerTeam(m_ID, team) == vcmpErrorArgumentOutOfBounds)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
STHROWF("Invalid team identifier: %d", team);
|
|
|
|
}
|
2016-08-17 14:49:08 +02:00
|
|
|
// 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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:52:22 +02:00
|
|
|
void CPlayer::SetSkin(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerSkin(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == skin)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
|
|
|
else if (_Func->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
|
|
|
STHROWF("Invalid skin identifier: %d", skin);
|
|
|
|
}
|
2016-08-17 14:52:22 +02:00
|
|
|
// 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);
|
|
|
|
}
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::SetColorEx(Uint8 r, Uint8 g, Uint8 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
|
|
|
|
_Func->SetPlayerColour(m_ID, SQMOD_PACK_RGB(r, g, b));
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:55:59 +02:00
|
|
|
void CPlayer::SetMoney(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerMoney(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == amount)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerMoney(m_ID, amount);
|
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, amount);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 14:55:59 +02:00
|
|
|
void CPlayer::GiveMoney(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerMoney(m_ID);
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->GivePlayerMoney(m_ID, amount);
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 15:00:28 +02:00
|
|
|
void CPlayer::SetScore(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerScore(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == score)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerScore(m_ID, score);
|
2016-08-17 15:00:28 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 15:04:14 +02:00
|
|
|
void CPlayer::SetWantedLevel(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerWantedLevel(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == level)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerWantedLevel(m_ID, level);
|
2016-08-17 15:04:14 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
return _Func->GetPlayerFPS(m_ID);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetHealth(Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetArmor(Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 15:07:31 +02:00
|
|
|
void CPlayer::SetImmunity(Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerImmunityFlags(m_ID);
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerImmunityFlags(m_ID, flags);
|
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
|
|
|
|
Core::Get().EmitPlayerImmunity(m_ID, current, 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetPositionEx(Float32 x, Float32 y, Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetSpeedEx(Float32 x, Float32 y, Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::AddSpeedEx(Float32 x, Float32 y, Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetHeading(Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 15:10:43 +02:00
|
|
|
void CPlayer::SetAlpha(Int32 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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-08-17 15:10:43 +02:00
|
|
|
void CPlayer::SetAlphaEx(Int32 alpha, Int32 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
|
|
|
|
const Int32 current = _Func->GetPlayerAlpha(m_ID);
|
|
|
|
// Don't even bother if it's the same value
|
|
|
|
if (current == alpha)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Avoid property unwind from a recursive call
|
2016-03-10 04:57:13 +01:00
|
|
|
_Func->SetPlayerAlpha(m_ID, alpha, fade);
|
2016-08-17 15:10:43 +02:00
|
|
|
// Avoid infinite recursive event loops
|
2016-08-18 13:20:41 +02:00
|
|
|
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);
|
|
|
|
}
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
bool CPlayer::Embark(CVehicle & vehicle) const
|
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();
|
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), 0, true, true)
|
|
|
|
!= 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
|
|
|
bool CPlayer::Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) const
|
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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Perform the requested operation
|
|
|
|
return (_Func->PutPlayerInVehicle(m_ID, vehicle.GetID(), slot, allocate, 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
|
const Int32 id = _Func->GetPlayerVehicleId(m_ID);
|
|
|
|
// 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetWeapon(Int32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon identifier: %d", 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::SetWeaponEx(Int32 wep, Int32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon ammo: %d", ammo);
|
|
|
|
}
|
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::GiveWeapon(Int32 wep, Int32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon ammo: %d", ammo);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetWeaponSlot(Int32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon slot: %d", slot);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CPlayer::GetWeaponAtSlot(Int32 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
|
|
|
|
const Int32 id = _Func->GetPlayerWeaponAtSlot(m_ID, slot);
|
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon slot: %d", slot);
|
|
|
|
}
|
|
|
|
// Return the requested information
|
|
|
|
return 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
|
|
|
Int32 CPlayer::GetAmmoAtSlot(Int32 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
|
|
|
|
const Int32 ammo = _Func->GetPlayerAmmoAtSlot(m_ID, slot);
|
|
|
|
// Check for errors
|
|
|
|
if (_Func->GetLastError() == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid weapon slot: %d", slot);
|
|
|
|
}
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::RemoveWeapon(Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetCameraPosition(Float32 xp, Float32 yp, Float32 zp, Float32 xa, Float32 ya, Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-06-15 05:06:03 +02:00
|
|
|
void CPlayer::SetAnimation(Int32 anim) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerAnimation(m_ID, 0, anim);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetAnimation(Int32 anim, Int32 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
|
|
|
|
const Int32 id = _Func->GetPlayerStandingOnVehicle(m_ID);
|
|
|
|
// 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
|
|
|
|
const Int32 id = _Func->GetPlayerStandingOnObject(m_ID);
|
|
|
|
// Validate the obtained identifier
|
|
|
|
if (VALID_ENTITYEX(id, SQMOD_OBJECT_POOL))
|
|
|
|
{
|
|
|
|
// Return the requested information
|
|
|
|
return Core::Get().GetObject(id).mObj;
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
const Int32 id = _Func->GetPlayerSpectateTarget(m_ID);
|
|
|
|
// 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
|
|
|
|
_Func->SetPlayerSpectateTarget(m_ID, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
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
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::InterpolateCameraLookAt(const Vector3 & pos, Uint32 ms) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->InterpolateCameraLookAt(m_ID, pos.x, pos.y, pos.z, ms) != vcmpErrorRequestDenied;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::InterpolateCameraLookAtEx(Float32 x, Float32 y, Float32 z, Uint32 ms) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->InterpolateCameraLookAt(m_ID, x, y, z, ms) != vcmpErrorRequestDenied;
|
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::Redirect(StackStrF & ip, Uint32 port, StackStrF & nick,
|
|
|
|
StackStrF & server_pass, StackStrF & user_pass)
|
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
|
|
|
{
|
|
|
|
STHROWF("Invalid arguments encountered");
|
|
|
|
}
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::PlaySound(Int32 sound_id) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->PlaySound(_Func->GetPlayerUniqueWorld(m_ID), sound_id, NAN, NAN, NAN);
|
|
|
|
}
|
|
|
|
|
2019-06-01 23:39:06 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetDrunkHandling(SQInteger level) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerDrunkHandling(m_ID, static_cast< Uint32 >(level));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
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
|
|
|
|
_Func->SetPlayerDrunkVisuals(m_ID, static_cast< Uint8 >(level));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
SQInteger CPlayer::GetDrunkVisuals() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
return _Func->GetPlayerDrunkVisuals(m_ID);
|
|
|
|
}
|
|
|
|
|
2016-06-24 22:37:58 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
|
2016-06-24 22:37:58 +02:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius) const
|
|
|
|
{
|
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,
|
2017-02-21 20:24:59 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj());
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpointEx(Int32 world, bool sphere, Float32 x, Float32 y, Float32 z,
|
2016-06-24 22:37:58 +02:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, Float32 radius,
|
2017-02-21 20:24:59 +01:00
|
|
|
Int32 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,
|
|
|
|
radius, header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos,
|
2016-06-24 22:37:58 +02:00
|
|
|
const Color4 & color, Float32 radius) const
|
|
|
|
{
|
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,
|
2017-02-21 20:24:59 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullLightObj());
|
2016-06-24 22:37:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
LightObj & CPlayer::CreateCheckpoint(Int32 world, bool sphere, const Vector3 & pos, const Color4 & color,
|
|
|
|
Float32 radius, Int32 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,
|
|
|
|
color.r, color.g, color.b, color.a, radius, header, payload);
|
|
|
|
}
|
|
|
|
|
2017-06-19 03:09:35 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
bool CPlayer::GetCollideAreas() const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return (Core::Get().GetPlayer(m_ID).mFlags & ENF_AREA_TRACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetAuthority(Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
const String & CPlayer::GetMessagePrefix(Uint32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Prefix index is out of range: %u >= %d", index, SQMOD_PLAYER_MSG_PREFIXES);
|
|
|
|
}
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2019-02-17 16:23:59 +01:00
|
|
|
void CPlayer::SetMessagePrefix(Uint32 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
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
STHROWF("Prefix index is out of range: %u >= %d", 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
|
2016-11-16 13:49:04 +01:00
|
|
|
mMessagePrefixes[index].assign(prefix.mPtr, 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2017-02-21 20:24:59 +01:00
|
|
|
void CPlayer::SetTrackPositionEx(SQInteger num, Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
|
|
}
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StartStream(Uint32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 CPlayer::GetBufferCursor() const
|
|
|
|
{
|
|
|
|
return m_Buffer.Position();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetBufferCursor(Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
m_Buffer.Move(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
|
2016-05-22 05:20:38 +02:00
|
|
|
m_Buffer.Push< Uint8 >(ConvTo< Uint8 >::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
|
2016-05-22 05:20:38 +02:00
|
|
|
m_Buffer.Push< Int16 >(ConvTo< Int16 >::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
|
|
|
|
m_Buffer.Push< Int32 >(ConvTo< Int32 >::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
|
|
|
|
m_Buffer.Push< Float32 >(ConvTo< Float32 >::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
|
2016-11-16 13:49:04 +01:00
|
|
|
Uint16 length = ConvTo< Uint16 >::From(val.mLen);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Change the size endianness to big endian
|
|
|
|
Uint16 size = ((length >> 8) & 0xFF) | ((length & 0xFF) << 8);
|
|
|
|
// Write the size and then the string contents
|
|
|
|
m_Buffer.Push< Uint16 >(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
|
2016-11-16 13:49:04 +01:00
|
|
|
m_Buffer.AppendS(val.mPtr, 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)
|
|
|
|
{
|
|
|
|
STHROWF("Stream buffer is too big");
|
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Uint32 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)
|
|
|
|
{
|
|
|
|
STHROWF("Stream buffer is too big");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
Float32 CPlayer::GetPositionX() const
|
|
|
|
{
|
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
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Float32 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
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetPositionX(Float32 x) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
2017-08-06 20:15:32 +02:00
|
|
|
// Reserve some temporary floats to retrieve the missing components
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetPositionY(Float32 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
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetPositionZ(Float32 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
|
2018-01-30 18:09:54 +01:00
|
|
|
Float32 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
|
2017-08-06 20:15:32 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, z, y, z);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 16) & 0xFF);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
return static_cast< Int32 >((_Func->GetPlayerColour(m_ID) >> 8) & 0xFF);
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
return static_cast< Int32 >(_Func->GetPlayerColour(m_ID) & 0xFF);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetColorR(Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(r) << 16) |
|
|
|
|
(~(0xFF << 16) & _Func->GetPlayerColour(m_ID)));
|
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::SetColorG(Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(g) << 8) |
|
|
|
|
(~(0xFF << 8) & _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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetColorB(Int32 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
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerColour(m_ID, (ConvTo< Uint8 >::From(g)) |
|
|
|
|
(~(0xFF) & _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
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("Invalid player reference [%s]", player->GetTag().c_str()));
|
|
|
|
}
|
|
|
|
|
|
|
|
// The index where the message should start
|
|
|
|
Int32 msgidx = 2;
|
|
|
|
// The message color
|
|
|
|
Uint32 color = 0;
|
|
|
|
// 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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
|
CPlayer * player = nullptr;
|
|
|
|
// 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
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
|
Uint32 index = 0;
|
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
|
|
|
{
|
|
|
|
index = ConvTo< Uint32 >::From(Var< SQInteger >(vm, 2).value);
|
|
|
|
}
|
|
|
|
catch (const Sqrat::Exception & e)
|
|
|
|
{
|
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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("Prefix index is out of range: %u >= %u",
|
2016-03-10 04:57:13 +01:00
|
|
|
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
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
vcmpError result = vcmpErrorNone;
|
|
|
|
// 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)
|
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
|
CPlayer * player = nullptr;
|
|
|
|
// 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
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
|
Uint32 index = 0;
|
|
|
|
// Attempt to extract the argument values
|
|
|
|
try
|
|
|
|
{
|
|
|
|
index = ConvTo< Uint32 >::From(Var< SQInteger >(vm, 2).value);
|
|
|
|
}
|
|
|
|
catch (const Sqrat::Exception & e)
|
|
|
|
{
|
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)
|
|
|
|
{
|
|
|
|
return sq_throwerror(vm, ToStrF("Prefix index is out of range: %u >= %u",
|
|
|
|
index, SQMOD_PLAYER_MSG_PREFIXES));
|
|
|
|
}
|
|
|
|
|
|
|
|
// The index where the message should start
|
|
|
|
Int32 msgidx = 3;
|
|
|
|
// The message color
|
|
|
|
Uint32 color = 0;
|
|
|
|
// 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
|
|
|
|
|
|
|
vcmpError result = vcmpErrorNone;
|
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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
|
CPlayer * player = nullptr;
|
|
|
|
// 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
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
|
CPlayer * player = nullptr;
|
|
|
|
// 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
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("Invalid announcement style %d [%s]",
|
|
|
|
player->mAnnounceStyle, player->GetTag().c_str()));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
else if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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)
|
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
const Int32 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
|
|
|
|
CPlayer * player = nullptr;
|
|
|
|
// The announcement style
|
|
|
|
Int32 style;
|
|
|
|
// 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;
|
|
|
|
style = Var< Int32 >(vm, 2).value;
|
2015-11-09 02:29:04 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
catch (const Sqrat::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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, "");
|
|
|
|
return sq_throwerror(vm, ToStrF("Invalid announcement style %d [%s]",
|
|
|
|
style, player->GetTag().c_str()));
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
|
|
|
else if (result == vcmpErrorTooLargeInput)
|
|
|
|
{
|
2016-06-19 17:39:12 +02:00
|
|
|
return sq_throwerror(vm, ToStrF("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
|
|
|
|
{
|
|
|
|
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
|
|
|
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
|
|
|
|
const Int32 id = std::round(static_cast< Float32 >(fid));
|
|
|
|
// 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
|
2017-08-06 16:01:59 +02:00
|
|
|
Int32 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
|
|
|
|
else 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_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
|
|
|
|
const Int32 id = std::round(static_cast< Float32 >(fid));
|
|
|
|
// 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
|
|
|
|
Int32 id = _Func->GetPlayerIdFromName(val.mPtr);
|
|
|
|
// 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)
|
2019-06-01 23:39:06 +02:00
|
|
|
.Prop(_SC("DrunkHandling"), &CPlayer::GetDrunkHandling, &CPlayer::SetDrunkHandling)
|
|
|
|
.Prop(_SC("DrunkVisuals"), &CPlayer::GetDrunkVisuals, &CPlayer::SetDrunkVisuals)
|
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)
|
|
|
|
.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)
|
2019-06-01 23:39:06 +02:00
|
|
|
.Func(_SC("Kill"), &CPlayer::Kill)
|
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)
|
2019-08-13 17:34:09 +02:00
|
|
|
.Func(_SC("GetNetworkStatisticsF"), &CPlayer::GetNetworkStatisticsF)
|
|
|
|
.Func(_SC("GetNetworkStatisticsI"), &CPlayer::GetNetworkStatisticsI)
|
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)
|
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)
|
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
|
2015-10-29 21:11:30 +01:00
|
|
|
.Overload< void (CPlayer::*)(const Vector3 &) const >
|
2016-02-20 23:25:00 +01:00
|
|
|
(_SC("AddSpeed"), &CPlayer::AddSpeed)
|
|
|
|
.Overload< void (CPlayer::*)(Float32, Float32, Float32) const >
|
|
|
|
(_SC("AddSpeed"), &CPlayer::AddSpeedEx)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Overload< bool (CPlayer::*)(CVehicle &) const >
|
|
|
|
(_SC("Embark"), &CPlayer::Embark)
|
|
|
|
.Overload< bool (CPlayer::*)(CVehicle &, SQInt32, bool, bool) const >
|
|
|
|
(_SC("Embark"), &CPlayer::Embark)
|
2015-11-11 08:02:42 +01:00
|
|
|
.Overload< void (CPlayer::*)(const Vector3 &, const Vector3 &) const >
|
2016-02-20 23:25:00 +01:00
|
|
|
(_SC("CameraPosition"), &CPlayer::SetCameraPosition)
|
|
|
|
.Overload< void (CPlayer::*)(Float32, Float32, Float32, Float32, Float32, Float32) const >
|
|
|
|
(_SC("CameraPosition"), &CPlayer::SetCameraPosition)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Overload< void (CPlayer::*)(void) >
|
|
|
|
(_SC("StartStream"), &CPlayer::StartStream)
|
|
|
|
.Overload< void (CPlayer::*)(Uint32) >
|
|
|
|
(_SC("StartStream"), &CPlayer::StartStream)
|
2016-06-15 05:06:03 +02:00
|
|
|
.Overload< void (CPlayer::*)(Int32) const >
|
|
|
|
(_SC("SetAnimation"), &CPlayer::SetAnimation)
|
|
|
|
.Overload< void (CPlayer::*)(Int32, Int32) const >
|
|
|
|
(_SC("SetAnimation"), &CPlayer::SetAnimation)
|
2017-02-21 20:24:59 +01:00
|
|
|
.Overload< LightObj & (CPlayer::*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32) const >
|
2016-06-24 22:37:58 +02:00
|
|
|
(_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx)
|
2017-02-21 20:24:59 +01:00
|
|
|
.Overload< LightObj & (CPlayer::*)(Int32, bool, Float32, Float32, Float32, Uint8, Uint8, Uint8, Uint8, Float32, Int32, LightObj &) const >
|
2016-06-24 22:37:58 +02:00
|
|
|
(_SC("CreateCheckpointEx"), &CPlayer::CreateCheckpointEx)
|
2017-02-21 20:24:59 +01:00
|
|
|
.Overload< LightObj & (CPlayer::*)(Int32, bool, const Vector3 &, const Color4 &, Float32) const >
|
2016-06-24 22:37:58 +02:00
|
|
|
(_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint)
|
2017-02-21 20:24:59 +01:00
|
|
|
.Overload< LightObj & (CPlayer::*)(Int32, bool, const Vector3 &, const Color4 &, Float32, Int32, LightObj &) const >
|
2016-06-24 22:37:58 +02:00
|
|
|
(_SC("CreateCheckpoint"), &CPlayer::CreateCheckpoint)
|
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
|