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-05-22 05:20:38 +02:00
|
|
|
#include "Library/Utils/BufferWrapper.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Core.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);
|
|
|
|
|
2015-10-29 21:11:30 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Color3 CPlayer::s_Color3;
|
|
|
|
Vector3 CPlayer::s_Vector3;
|
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-03-10 04:57:13 +01:00
|
|
|
SQInteger CPlayer::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
static const SQChar name[] = _SC("SqPlayer");
|
2016-03-10 04:57:13 +01:00
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
2015-11-07 11:17:39 +01:00
|
|
|
|
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-02-20 23:25:00 +01:00
|
|
|
Int32 CPlayer::Cmp(const CPlayer & o) const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
if (m_ID == o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 0;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
else if (m_ID > o.m_ID)
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return 1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
else
|
2016-05-22 05:20:38 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2016-05-22 05:20:38 +02:00
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CPlayer::ToString() const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CPlayer::GetTag() const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetTag(CSStr tag)
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
m_Tag.assign(tag);
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetData(Object & 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
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
void CPlayer::BindEvent(Int32 evid, Object & env, Function & func) const
|
2015-11-09 04:54:03 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Obtain the function instance called for this event
|
2016-05-22 05:20:38 +02:00
|
|
|
Function & event = Core::Get().GetPlayerEvent(m_ID, evid);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified callback function null?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (func.IsNull())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-24 20:36:49 +02:00
|
|
|
event.ReleaseGently(); // Then release the current callback
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-24 06:29:14 +02:00
|
|
|
// Does this function need a custom environment?
|
|
|
|
else if (env.IsNull())
|
|
|
|
{
|
|
|
|
event = func;
|
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Assign the specified environment and function
|
2015-11-09 04:54:03 +01:00
|
|
|
else
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
event = Function(env.GetVM(), env, func.GetFunc());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
void CPlayer::SetAdmin(bool toggle) 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->SetPlayerAdmin(m_ID, 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;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
// 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();
|
|
|
|
// 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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetName(CSStr name) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-05-24 07:26:47 +02:00
|
|
|
if (_Func->SetPlayerName(m_ID, name) == vcmpErrorInvalidName)
|
|
|
|
{
|
|
|
|
STHROWF("The specified name is invalid");
|
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id));
|
2016-06-14 03:42:18 +02:00
|
|
|
// Do we even have to modify the specified option?
|
|
|
|
if (value == toggle)
|
|
|
|
{
|
|
|
|
return; // Nothing to change!
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to modify the current value of the specified option
|
2016-06-14 03:42:18 +02:00
|
|
|
else if (_Func->SetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id),
|
2016-05-22 05:20:38 +02:00
|
|
|
toggle) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: %d", option_id);
|
|
|
|
}
|
|
|
|
else if (!(m_CircularLocks & PCL_EMIT_PLAYER_OPTION))
|
|
|
|
{
|
|
|
|
Core::Get().EmitPlayerOption(m_ID, option_id, value, 0, NullObject());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetOptionEx(Int32 option_id, bool toggle, Int32 header, Object & payload)
|
|
|
|
{
|
|
|
|
// Attempt to obtain the current value of the specified option
|
|
|
|
const bool value = _Func->GetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id));
|
2016-06-14 03:42:18 +02:00
|
|
|
// Do we even have to modify the specified option?
|
|
|
|
if (value == toggle)
|
|
|
|
{
|
|
|
|
return; // Nothing to change!
|
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Attempt to modify the current value of the specified option
|
2016-06-14 03:42:18 +02:00
|
|
|
else if (_Func->SetPlayerOption(m_ID, static_cast< vcmpPlayerOption >(option_id),
|
2016-05-22 05:20:38 +02:00
|
|
|
toggle) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid option identifier: %d", option_id);
|
|
|
|
}
|
|
|
|
else if (!(m_CircularLocks & PCL_EMIT_PLAYER_OPTION))
|
|
|
|
{
|
|
|
|
// Prevent this event from triggering while executed
|
|
|
|
BitGuardU32 bg(m_CircularLocks, PCL_EMIT_PLAYER_OPTION);
|
2016-06-14 03:42:18 +02:00
|
|
|
// Now forward the event call
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Get().EmitPlayerOption(m_ID, option_id, value, header, payload);
|
|
|
|
}
|
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::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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetWorld(Int32 world) 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->SetPlayerWorld(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::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-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetSecondaryWorld(Int32 world) 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->SetPlayerSecondaryWorld(m_ID, world);
|
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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetTeam(Int32 team) 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->SetPlayerTeam(m_ID, team) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid team identifier: %d", 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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetSkin(Int32 skin) 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->SetPlayerSkin(m_ID, skin) == vcmpErrorArgumentOutOfBounds)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid skin identifier: %d", skin);
|
|
|
|
}
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const 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();
|
|
|
|
// Clear previous color information, if any
|
2015-10-29 21:11:30 +01:00
|
|
|
s_Color3.Clear();
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the color values
|
|
|
|
s_Color3.SetRGB(_Func->GetPlayerColour(m_ID));
|
|
|
|
// Return the requested information
|
2015-10-29 21:11:30 +01:00
|
|
|
return s_Color3;
|
|
|
|
}
|
|
|
|
|
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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetMoney(Int32 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->SetPlayerMoney(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
|
|
|
void CPlayer::GiveMoney(Int32 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->GivePlayerMoney(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::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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetScore(Int32 score) 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->SetPlayerScore(m_ID, 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-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetWantedLevel(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
|
|
|
|
_Func->SetPlayerWantedLevel(m_ID, 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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetImmunity(Int32 flags) 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->SetPlayerImmunityFlags(m_ID, flags);
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const 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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear previous information, if any
|
2015-10-29 21:11:30 +01:00
|
|
|
s_Vector3.Clear();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Query the server for the values
|
|
|
|
_Func->GetPlayerPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2015-10-29 21:11:30 +01:00
|
|
|
return s_Vector3;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-11-01 04:48:01 +01:00
|
|
|
const 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();
|
|
|
|
// Clear previous speed information, if any
|
2015-10-29 21:11:30 +01:00
|
|
|
s_Vector3.Clear();
|
2016-03-10 04:57:13 +01:00
|
|
|
// Query the server for the speed values
|
|
|
|
_Func->GetPlayerSpeed(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
|
|
|
|
// Return the requested information
|
2015-10-29 21:11:30 +01:00
|
|
|
return s_Vector3;
|
|
|
|
}
|
|
|
|
|
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-02-20 23:25:00 +01:00
|
|
|
void CPlayer::SetAlpha(Int32 alpha, Int32 fade) 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->SetPlayerAlpha(m_ID, alpha, fade);
|
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::GetAimPosition() 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 previous information, if any
|
|
|
|
s_Vector3.Clear();
|
|
|
|
// Query the server for the values
|
|
|
|
_Func->GetPlayerAimPosition(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return s_Vector3;
|
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::GetAimDirection() 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 previous direction information, if any
|
|
|
|
s_Vector3.Clear();
|
|
|
|
// Query the server for the direction values
|
|
|
|
_Func->GetPlayerAimDirection(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return s_Vector3;
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Object & 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
|
|
|
|
return NullObject();
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Object & 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
|
|
|
|
return NullObject();
|
2015-10-29 21:11:30 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Object & 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
|
|
|
|
return NullObject();
|
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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
Object & 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
|
|
|
|
return NullObject();
|
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::SetSpectator(CPlayer & target) const
|
2015-10-29 21:11:30 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Is the specified player even valid?
|
|
|
|
if (!target.IsActive())
|
|
|
|
{
|
|
|
|
STHROWF("Invalid player 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
|
|
|
_Func->SetPlayerSpectateTarget(m_ID, target.GetID());
|
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::Redirect(CSStr ip, Uint32 port, CSStr nick, CSStr server_pass, CSStr 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-05-22 05:20:38 +02:00
|
|
|
if (_Func->RedirectPlayerToServer(m_ID, ip, port,
|
|
|
|
nick, server_pass, user_pass) == vcmpErrorNullArgument)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid arguments encountered");
|
|
|
|
}
|
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::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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::SetMessagePrefix(Uint32 index, CSStr 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-05-22 05:20:38 +02:00
|
|
|
mMessagePrefixes[index].assign(prefix);
|
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-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
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-05-22 05:20:38 +02:00
|
|
|
void CPlayer::StreamString(CSStr 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
|
|
|
// Is the given string value even valid?
|
|
|
|
if (!val)
|
|
|
|
{
|
|
|
|
STHROWF("Invalid string argument: null");
|
|
|
|
}
|
|
|
|
// Calculate the string length
|
|
|
|
Uint16 length = ConvTo< Uint16 >::From(std::strlen(val));
|
|
|
|
// 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);
|
|
|
|
m_Buffer.AppendS(val, length);
|
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::StreamRawString(CSStr val)
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Is the given string value even valid?
|
|
|
|
if (!val)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-05-22 05:20:38 +02:00
|
|
|
STHROWF("Invalid string argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-05-22 05:20:38 +02:00
|
|
|
// Calculate the string length
|
|
|
|
Uint16 length = ConvTo< Uint16 >::From(std::strlen(val));
|
|
|
|
// Write the the string contents
|
|
|
|
m_Buffer.AppendS(val, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SendBuffer(const BufferWrapper & buffer) const
|
|
|
|
{
|
|
|
|
// 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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear previous information, if any
|
|
|
|
s_Vector3.x = 0;
|
|
|
|
// Query the server for the requested component value
|
|
|
|
_Func->GetPlayerPosition(m_ID, &s_Vector3.x, nullptr, nullptr);
|
|
|
|
// Return the requested information
|
|
|
|
return s_Vector3.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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear previous information, if any
|
|
|
|
s_Vector3.y = 0;
|
|
|
|
// Query the server for the requested component value
|
|
|
|
_Func->GetPlayerPosition(m_ID, nullptr, &s_Vector3.y, nullptr);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Return the requested information
|
2016-05-22 05:20:38 +02:00
|
|
|
return s_Vector3.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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Clear previous information, if any
|
|
|
|
s_Vector3.z = 0;
|
|
|
|
// Query the server for the requested component value
|
|
|
|
_Func->GetPlayerPosition(m_ID, nullptr, nullptr, &s_Vector3.z);
|
|
|
|
// Return the requested information
|
|
|
|
return s_Vector3.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
void CPlayer::SetPositionX(Float32 x) const
|
|
|
|
{
|
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Retrieve the current values for unchanged components
|
|
|
|
_Func->GetPlayerPosition(m_ID, nullptr, &s_Vector3.y, &s_Vector3.z);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, x, s_Vector3.y, s_Vector3.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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Retrieve the current values for unchanged components
|
|
|
|
_Func->GetPlayerPosition(m_ID, &s_Vector3.x, nullptr, &s_Vector3.z);
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetPlayerPosition(m_ID, s_Vector3.x, y, s_Vector3.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();
|
2016-05-22 05:20:38 +02:00
|
|
|
// Retrieve the current values for unchanged components
|
|
|
|
_Func->GetPlayerPosition(m_ID, &s_Vector3.x, &s_Vector3.y, nullptr);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Perform the requested operation
|
2016-05-22 05:20:38 +02:00
|
|
|
_Func->SetPlayerPosition(m_ID, s_Vector3.z, s_Vector3.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
|
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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
|
2016-06-19 17:39:12 +02:00
|
|
|
StackStrF val(vm, msgidx);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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)
|
|
|
|
{
|
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
StackStrF val(vm, 3);
|
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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)
|
|
|
|
{
|
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
2016-06-19 17:39:12 +02:00
|
|
|
StackStrF val(vm, msgidx);
|
2016-05-22 05:20:38 +02:00
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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
|
|
|
|
StackStrF val(vm, 2);
|
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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
|
|
|
|
StackStrF val(vm, 2);
|
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 04:57:13 +01:00
|
|
|
return sq_throwerror(vm, e.Message().c_str());
|
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
|
|
|
|
StackStrF val(vm, 3);
|
|
|
|
// Have we failed to retrieve the string?
|
|
|
|
if (SQ_FAILED(val.mRes))
|
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-03-10 05:18:39 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static const Object & Player_FindByID(Int32 id)
|
|
|
|
{
|
|
|
|
// Perform a range check on the specified identifier
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified player identifier is invalid: %d", id);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
|
|
|
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
2016-03-10 05:18:39 +01:00
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does the identifier match the specified one?
|
|
|
|
if (itr->mID == id)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 05:18:39 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a player matching the specified identifier
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:17:12 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 05:18:39 +01:00
|
|
|
static const Object & Player_FindByTag(CSStr tag)
|
|
|
|
{
|
|
|
|
// Perform a validity check on the specified tag
|
2016-03-12 21:51:44 +01:00
|
|
|
if (!tag || *tag == '\0')
|
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified player tag is invalid: null/empty");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
|
|
|
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
2016-03-10 05:18:39 +01:00
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does this entity even exist and does the tag match the specified one?
|
|
|
|
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 05:18:39 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a player matching the specified tag
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:17:12 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Array Player_FindActive()
|
|
|
|
{
|
|
|
|
// Remember the initial stack size
|
|
|
|
StackGuard sg;
|
|
|
|
// Obtain the ends of the entity pool
|
2016-05-22 05:20:38 +02:00
|
|
|
Core::Players::const_iterator itr = Core::Get().GetPlayers().cbegin();
|
|
|
|
Core::Players::const_iterator end = Core::Get().GetPlayers().cend();
|
2016-03-26 17:17:12 +01:00
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Is this entity instance active?
|
|
|
|
if (VALID_ENTITY(itr->mID))
|
|
|
|
{
|
|
|
|
// Push the script object on the stack
|
|
|
|
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
|
|
|
|
// Append the object at the back of the array
|
|
|
|
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
|
|
|
|
{
|
|
|
|
STHROWF("Unable to append entity instance to the list");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
|
|
|
|
2016-05-22 05:20:38 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static const Object & Player_FindAuto(Object & by)
|
|
|
|
{
|
|
|
|
switch (by.GetType())
|
|
|
|
{
|
|
|
|
case OT_INTEGER:
|
|
|
|
{
|
|
|
|
return Core::Get().GetPlayer(by.Cast< Int32 >()).mObj;
|
|
|
|
} break;
|
|
|
|
case OT_FLOAT:
|
|
|
|
{
|
|
|
|
return Core::Get().GetPlayer(std::round(by.Cast< Float32 >())).mObj;
|
|
|
|
} break;
|
|
|
|
case OT_STRING:
|
|
|
|
{
|
|
|
|
// Obtain the argument as a string
|
|
|
|
String str(by.Cast< String >());
|
|
|
|
// Attempt to locate the player with this name
|
|
|
|
Int32 id = _Func->GetPlayerIdFromName(&str[0]);
|
|
|
|
// Was there a player with this name?
|
|
|
|
if (VALID_ENTITYEX(id, SQMOD_PLAYER_POOL))
|
|
|
|
{
|
|
|
|
Core::Get().GetPlayer(id).mObj;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
default: STHROWF("Unsupported search identifier");
|
|
|
|
}
|
|
|
|
// Default to a null object
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:11:30 +01:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CPlayer(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
RootTable(vm).Bind(_SC("SqPlayer"),
|
|
|
|
Class< CPlayer, NoConstructor< CPlayer > >(vm, _SC("SqPlayer"))
|
2016-06-03 20:26:19 +02:00
|
|
|
// Meta-methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_cmp"), &CPlayer::Cmp)
|
2016-03-10 04:57:13 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &CPlayer::Typename)
|
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
|
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-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Bind"), &CPlayer::BindEvent)
|
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)
|
|
|
|
.Prop(_SC("Authority"), &CPlayer::GetAuthority, &CPlayer::SetAuthority)
|
2016-06-08 15:53:16 +02:00
|
|
|
.Prop(_SC("TrackPosition"), &CPlayer::GetTrackPosition, &CPlayer::SetTrackPosition)
|
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)
|
|
|
|
.Func(_SC("Kick"), &CPlayer::Kick)
|
|
|
|
.Func(_SC("Ban"), &CPlayer::Ban)
|
2016-05-22 05:20:38 +02:00
|
|
|
.Func(_SC("GetOption"), &CPlayer::GetOption)
|
|
|
|
.Func(_SC("SetOption"), &CPlayer::SetOption)
|
|
|
|
.Func(_SC("SetOptionEx"), &CPlayer::SetOptionEx)
|
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-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)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Spectate"), &CPlayer::SetSpectator)
|
|
|
|
.Func(_SC("Redirect"), &CPlayer::Redirect)
|
|
|
|
.Func(_SC("GetMsgPrefix"), &CPlayer::GetMessagePrefix)
|
|
|
|
.Func(_SC("SetMsgPrefix"), &CPlayer::SetMessagePrefix)
|
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)
|
|
|
|
.Func(_SC("StreamString"), &CPlayer::StreamString)
|
|
|
|
.Func(_SC("StreamRawString"), &CPlayer::StreamRawString)
|
|
|
|
.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)
|
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-03-10 05:18:39 +01:00
|
|
|
// Static Functions
|
2016-05-22 05:20:38 +02:00
|
|
|
.StaticFunc(_SC("Find"), &Player_FindAuto)
|
2016-03-10 05:18:39 +01:00
|
|
|
.StaticFunc(_SC("FindByID"), &Player_FindByID)
|
|
|
|
.StaticFunc(_SC("FindByTag"), &Player_FindByTag)
|
2016-03-26 17:17:12 +01:00
|
|
|
.StaticFunc(_SC("FindActive"), &Player_FindActive)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|