From 772822415b6bbe1c40c157dc0047a0f4df889778 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 29 Oct 2015 22:11:30 +0200 Subject: [PATCH] Untested implementation of the Player type. --- source/Entity/Player.cpp | 1801 +++++++++++++++++++++++++++++++++++++- source/Entity/Player.hpp | 584 +++++++++++- 2 files changed, 2374 insertions(+), 11 deletions(-) diff --git a/source/Entity/Player.cpp b/source/Entity/Player.cpp index 938425a5..60ce85a8 100644 --- a/source/Entity/Player.cpp +++ b/source/Entity/Player.cpp @@ -1,28 +1,1811 @@ #include "Entity/Player.hpp" +#include "Base/Color3.hpp" +#include "Misc/Skin.hpp" +#include "Misc/Weapon.hpp" #include "Register.hpp" // ------------------------------------------------------------------------------------------------ namespace SqMod { // ------------------------------------------------------------------------------------------------ -bool Register_CPlayer(HSQUIRRELVM vm) -{ - if (!Register_Reference< CPlayer >(vm, _SC("BasePlayer"))) - { - LogDbg("Unable to register the base class for type"); +CSkin CPlayer::s_Skin; +CWeapon CPlayer::s_Weapon; - return false; +// ------------------------------------------------------------------------------------------------ +Color3 CPlayer::s_Color3; +Vector3 CPlayer::s_Vector3; + +// ------------------------------------------------------------------------------------------------ +SQChar CPlayer::s_Buffer[128]; + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsStreamedFor(const Reference < CPlayer > & player) const noexcept +{ + if (VALID_ENTITY(m_ID) && player) + { + return _Func->IsPlayerStreamedForPlayer(m_ID, player); + } + else if (!player) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(player)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); } - LogDbg("Beginning registration of type"); + return false; +} +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetClass() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerClass(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetAdmin() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerAdmin(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetAdmin(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerAdmin(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * CPlayer::GetIP() const noexcept +{ + // Clear any previous ip address + s_Buffer[0] = '\0'; + // Attempt to retrieve the ip address + if (VALID_ENTITY(m_ID)) + { + std::memset(s_Buffer, '\0', std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + _Func->GetPlayerIP(m_ID, s_Buffer, std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the ip address that could be retrieved + return s_Buffer; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Kick() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->KickPlayer(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Ban() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->BanPlayer(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsConnected() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerConnected(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsSpawned() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerSpawned(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +SQUnsignedInteger CPlayer::GetKey() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerKey(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_BLANK; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetWorld() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerWorld(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWorld(SQInt32 world) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerWorld(m_ID, world); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetSecWorld() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerSecWorld(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetSecWorld(SQInt32 world) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerSecWorld(m_ID, world); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetUniqueWorld() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerUniqueWorld(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsWorldCompatible(SQInt32 world) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerWorldCompatible(m_ID, world); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetState() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerState(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * CPlayer::GetName() const noexcept +{ + // Clear any previous ip address + s_Buffer[0] = '\0'; + // Attempt to retrieve the ip address + if (VALID_ENTITY(m_ID)) + { + std::memset(s_Buffer, '\0', std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + _Func->GetPlayerName(m_ID, s_Buffer, std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the ip address that could be retrieved + return s_Buffer; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetName(const SQChar * name) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerName(m_ID, static_cast< const char * >(name)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetTeam() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerTeam(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetTeam(SQInt32 team) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerTeam(m_ID, team); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const CSkin & CPlayer::GetSkin() const noexcept +{ + // Clear any previous skin + s_Skin.SetID(SQMOD_UNKNOWN); + // Attempt to retrieve the skin + if (VALID_ENTITY(m_ID)) + { + s_Skin.SetID(_Func->GetPlayerSkin(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the skin that could be retrieved + return s_Skin; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetSkin(const CSkin & skin) const noexcept +{ + if (VALID_ENTITY(m_ID) && skin) + { + _Func->SetPlayerSkin(m_ID, skin); + } + else if (!skin) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(skin)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetSkinID() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerSkin(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetSkinID(SQInt32 skin) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerSkin(m_ID, skin); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const Color3 & CPlayer::GetColor() const noexcept +{ + // Clear any previous color + s_Color3.Clear(); + // Attempt to retrieve the color + if (VALID_ENTITY(m_ID)) + { + s_Color3.SetRGB(_Func->GetPlayerColour(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the color that could be retrieved + return s_Color3; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetColor(const Color3 & color) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerColour(m_ID, color.GetRGB()); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetColorEx(Uint8 r, Uint8 g, Uint8 b) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerColour(m_ID, PACK_RGB(r, g, b)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::ForceSpawn() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->ForcePlayerSpawn(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::ForceSelect() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->ForcePlayerSelect(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetMoney() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerMoney(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetMoney(SQInt32 amount) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerMoney(m_ID, amount); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::GiveMoney(SQInt32 amount) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->GivePlayerMoney(m_ID, amount); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetScore() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerScore(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetScore(SQInt32 score) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerScore(m_ID, score); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetPing() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerPing(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +SQFloat CPlayer::GetFPS() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerFPS(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return 0.0; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsTyping() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerTyping(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * CPlayer::GetUID() const noexcept +{ + // Clear any previous uid + s_Buffer[0] = '\0'; + // Attempt to retrieve the uid + if (VALID_ENTITY(m_ID)) + { + std::memset(s_Buffer, '\0', std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + _Func->GetPlayerUID(m_ID, s_Buffer, std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the uid that could be retrieved + return s_Buffer; +} + +// ------------------------------------------------------------------------------------------------ +const SQChar * CPlayer::GetUID2() const noexcept +{ + // Clear any previous uid2 + s_Buffer[0] = '\0'; + // Attempt to retrieve the uid2 + if (VALID_ENTITY(m_ID)) + { + std::memset(s_Buffer, '\0', std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + _Func->GetPlayerUID2(m_ID, s_Buffer, std::extent< decltype(s_Buffer) >::value * sizeof(SQChar)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the uid2 that could be retrieved + return s_Buffer; +} + +// ------------------------------------------------------------------------------------------------ +SQFloat CPlayer::GetHealth() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerHealth(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return 0.0; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetHealth(SQFloat amount) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerHealth(m_ID, amount); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQFloat CPlayer::GetArmour() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerArmour(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetArmour(SQFloat amount) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerArmour(m_ID, amount); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetImmunity() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerImmunityFlags(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetImmunity(SQInt32 flags) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerImmunityFlags(m_ID, flags); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const Vector3 & CPlayer::GetPosition() const noexcept +{ + // Clear any previous position + s_Vector3.Clear(); + // Attempt to retrieve the position + if (VALID_ENTITY(m_ID)) + { + _Func->GetPlayerPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the position that could be retrieved + return s_Vector3; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetPosition(const Vector3 & pos) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerPos(m_ID, pos.x, pos.y, pos.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerPos(m_ID, x, y, z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const Vector3 & CPlayer::GetSpeed() const noexcept +{ + // Clear any previous speed + s_Vector3.Clear(); + // Attempt to retrieve the speed + if (VALID_ENTITY(m_ID)) + { + _Func->GetPlayerSpeed(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the speed that could be retrieved + return s_Vector3; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetSpeed(const Vector3 & vel) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerSpeed(m_ID, vel.x, vel.y, vel.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetSpeedEx(SQFloat x, SQFloat y, SQFloat z) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerSpeed(m_ID, x, y, z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::AddSpeed(const Vector3 & vel) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->AddPlayerSpeed(m_ID, vel.x, vel.y, vel.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::AddSpeedEx(SQFloat x, SQFloat y, SQFloat z) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->AddPlayerSpeed(m_ID, x, y, z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQFloat CPlayer::GetHeading() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerHeading(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetHeading(SQFloat angle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerHeading(m_ID, angle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetAlpha() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerAlpha(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetAlpha(SQInt32 alpha, SQInt32 fade) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerAlpha(m_ID, alpha, fade); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetVehicleStatus() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerInVehicleStatus(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetOccupiedSlot() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerInVehicleSlot(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +Reference < CVehicle > CPlayer::GetVehicle() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return Reference < CVehicle >(_Func->GetPlayerVehicleID(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return Reference < CVehicle >(); +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetVehicleID() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerVehicleID(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetControllable() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerControllable(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetControllable(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerControllable(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetDriveby() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerDriveby(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetDriveby(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerDriveby(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetWhiteScanlines() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerWhiteScanlines(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWhiteScanlines(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerWhiteScanlines(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetGreenScanlines() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerGreenScanlines(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetGreenScanlines(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerGreenScanlines(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetWidescreen() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerWidescreen(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWidescreen(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerWidescreen(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetShowMarkers() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerShowMarkers(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetShowMarkers(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerShowMarkers(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetAttackPriv() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerAttackPriv(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetAttackPriv(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerAttackPriv(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetHasMarker() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerHasMarker(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetHasMarker(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerHasMarker(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetChatTags() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerChatTags(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetChatTags(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerChatTagsEnabled(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::GetDrunkEffects() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->EnabledPlayerDrunkEffects(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetDrunkEffects(bool toggle) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->TogglePlayerDrunkEffects(m_ID, toggle); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +const CWeapon & CPlayer::GetWeapon() const noexcept +{ + // Clear any previous weapon + s_Weapon.SetID(SQMOD_UNKNOWN); + // Attempt to retrieve the weapon + if (VALID_ENTITY(m_ID)) + { + s_Weapon.SetID(_Func->GetPlayerWeapon(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the model that could be weapon + return s_Weapon; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWeapon(const CWeapon & wep) const noexcept +{ + if (VALID_ENTITY(m_ID) && wep) + { + _Func->SetPlayerWeapon(m_ID, wep, wep.GetAmmo()); + } + else if (!wep) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(wep)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWeaponEx(const CWeapon & wep, SQInt32 ammo) const noexcept +{ + if (VALID_ENTITY(m_ID) && wep) + { + _Func->SetPlayerWeapon(m_ID, wep, ammo); + } + else if (!wep) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(wep)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetWeaponID() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerWeapon(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWeaponID(SQInt32 wep) const noexcept +{ + if (VALID_ENTITY(m_ID) && VALID_ENTITY(wep)) + { + _Func->SetPlayerWeapon(m_ID, wep, 0); + } + else if (!VALID_ENTITY(wep)) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), wep); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWeaponIDEx(SQInt32 wep, SQInt32 ammo) const noexcept +{ + if (VALID_ENTITY(m_ID) && VALID_ENTITY(wep)) + { + _Func->SetPlayerWeapon(m_ID, wep, ammo); + } + else if (!VALID_ENTITY(wep)) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), wep); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::GiveWeapon(const CWeapon & wep) const noexcept +{ + if (VALID_ENTITY(m_ID) && wep) + { + _Func->GivePlayerWeapon(m_ID, wep, wep.GetAmmo()); + } + else if (!wep) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(wep)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::GiveWeaponEx(const CWeapon & wep, SQInt32 ammo) const noexcept +{ + if (VALID_ENTITY(m_ID) && wep) + { + _Func->GivePlayerWeapon(m_ID, wep, ammo); + } + else if (!wep) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(wep)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::GiveWeaponIDEx(SQInt32 wep, SQInt32 ammo) const noexcept +{ + if (VALID_ENTITY(m_ID) && VALID_ENTITY(wep)) + { + _Func->GivePlayerWeapon(m_ID, wep, ammo); + } + else if (!VALID_ENTITY(wep)) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), wep); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::StripWeapons() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->RemoveAllWeapons(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetCameraPosition(const Vector3 & pos, const Vector3 & aim) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetCameraPosition(m_ID, pos.x, pos.y, pos.z, aim.x, aim.y, aim.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::RestoreCamera() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->RestoreCamera(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsCameraLocked() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsCameraLocked(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetAnimation(SQInt32 group, SQInt32 anim) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerAnimation(m_ID, group, anim); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetWantedLevel() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerWantedLevel(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::SetWantedLevel(SQInt32 level) const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->SetPlayerWantedLevel(m_ID, level); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +Reference < CVehicle > CPlayer::StandingOnVehicle() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return Reference < CVehicle >(_Func->GetPlayerStandingOnVehicle(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return Reference < CVehicle >(); +} + +// ------------------------------------------------------------------------------------------------ +Reference < CObject > CPlayer::StandingOnObject() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return Reference < CObject >(_Func->GetPlayerStandingOnObject(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return Reference < CObject >(); +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsAway() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->IsPlayerAway(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +Reference < CPlayer > CPlayer::Spectating() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return Reference < CPlayer >(_Func->GetPlayerSpectateTarget(m_ID)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return Reference < CPlayer >(); +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Spectate(const Reference < CPlayer > & target) const noexcept +{ + if (VALID_ENTITY(m_ID) && target) + { + _Func->SetPlayerSpectateTarget(m_ID, target); + } + else if (!target) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(target)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsBurning() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerOnFireStatus(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::IsCrouched() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerCrouchStatus(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetAction() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerAction(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +SQInt32 CPlayer::GetGameKeys() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->GetPlayerGameKeys(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return SQMOD_UNKNOWN; +} + +// ------------------------------------------------------------------------------------------------ +const Vector3 & CPlayer::GetAimPos() const noexcept +{ + // Clear any previous aim position + s_Vector3.Clear(); + // Attempt to retrieve the aim position + if (VALID_ENTITY(m_ID)) + { + _Func->GetPlayerAimPos(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the aim position that could be retrieved + return s_Vector3; +} + +// ------------------------------------------------------------------------------------------------ +const Vector3 & CPlayer::GetAimDir() const noexcept +{ + // Clear any previous aim direction + s_Vector3.Clear(); + // Attempt to retrieve the aim direction + if (VALID_ENTITY(m_ID)) + { + _Func->GetPlayerAimDir(m_ID, &s_Vector3.x, &s_Vector3.y, &s_Vector3.z); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + // Return the aim direction that could be retrieved + return s_Vector3; +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Embark(const Reference < CVehicle > & vehicle) const noexcept +{ + if (VALID_ENTITY(m_ID) && vehicle) + { + _Func->PutPlayerInVehicle(m_ID, vehicle, 0, true, true); + } + else if (!vehicle) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(vehicle)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Embark(const Reference < CVehicle > & vehicle, SQInt32 slot, bool allocate, bool warp) const noexcept +{ + if (VALID_ENTITY(m_ID) && vehicle) + { + _Func->PutPlayerInVehicle(m_ID, vehicle, slot, allocate, warp); + } + else if (!vehicle) + { + LogWrn(_SC("Attempting to using an invalid argument: %d"), _SCI32(vehicle)); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +void CPlayer::Disembark() const noexcept +{ + if (VALID_ENTITY(m_ID)) + { + _Func->RemovePlayerFromVehicle(m_ID); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } +} + +// ------------------------------------------------------------------------------------------------ +bool CPlayer::Redirect(const SQChar * ip, SQUnsignedInteger port, const SQChar * nick, \ + const SQChar * pass, const SQChar * user) noexcept +{ + if (VALID_ENTITY(m_ID)) + { + return _Func->RedirectPlayerToServer(m_ID, ip, port, nick, pass, user); + } + else + { + LogWrn(_SC("Attempting to using an invalid reference: %d"), m_ID); + } + + return false; +} + +// ================================================================================================ +bool Register_CPlayer(HSQUIRRELVM vm) +{ + // Attempt to register the base reference type before the actual implementation + if (!Register_Reference< CPlayer >(vm, _SC("BasePlayer"))) + { + LogFtl("Unable to register the base class for type"); + // Registration failed + return false; + } + // Output debugging information + LogDbg("Beginning registration of type"); + // Attempt to register the actual reference that implements all of the entity functionality Sqrat::RootTable(vm).Bind(_SC("CPlayer"), Sqrat::DerivedClass< CPlayer, Reference< CPlayer > >(vm, _SC("CPlayer")) + /* Constructors */ .Ctor() .Ctor< SQInt32 >() + /* Properties */ + .Prop(_SC("cls"), &CPlayer::GetClass) + .Prop(_SC("admin"), &CPlayer::GetAdmin, &CPlayer::SetAdmin) + .Prop(_SC("ip"), &CPlayer::GetIP) + .Prop(_SC("connected"), &CPlayer::IsConnected) + .Prop(_SC("spawned"), &CPlayer::IsSpawned) + .Prop(_SC("key"), &CPlayer::GetKey) + .Prop(_SC("world"), &CPlayer::GetWorld, &CPlayer::SetWorld) + .Prop(_SC("sec_world"), &CPlayer::GetSecWorld, &CPlayer::SetSecWorld) + .Prop(_SC("unique_world"), &CPlayer::GetUniqueWorld) + .Prop(_SC("state"), &CPlayer::GetState) + .Prop(_SC("name"), &CPlayer::GetName, &CPlayer::SetName) + .Prop(_SC("team"), &CPlayer::GetTeam, &CPlayer::SetTeam) + .Prop(_SC("skin"), &CPlayer::GetSkin, &CPlayer::SetSkin) + .Prop(_SC("skin_id"), &CPlayer::GetSkinID, &CPlayer::SetSkinID) + .Prop(_SC("color"), &CPlayer::GetColor, &CPlayer::SetColor) + .Prop(_SC("money"), &CPlayer::GetMoney, &CPlayer::SetMoney) + .Prop(_SC("score"), &CPlayer::GetScore, &CPlayer::SetScore) + .Prop(_SC("ping"), &CPlayer::GetPing) + .Prop(_SC("fps"), &CPlayer::GetFPS) + .Prop(_SC("typing"), &CPlayer::IsTyping) + .Prop(_SC("uid"), &CPlayer::GetUID) + .Prop(_SC("uid2"), &CPlayer::GetUID2) + .Prop(_SC("health"), &CPlayer::GetHealth, &CPlayer::SetHealth) + .Prop(_SC("armour"), &CPlayer::GetArmour, &CPlayer::SetArmour) + .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) + .Prop(_SC("vehicle_status"), &CPlayer::GetVehicleStatus) + .Prop(_SC("slot"), &CPlayer::GetOccupiedSlot) + .Prop(_SC("vehicle"), &CPlayer::GetVehicle) + .Prop(_SC("vehicle_id"), &CPlayer::GetVehicleID) + .Prop(_SC("controllable"), &CPlayer::GetControllable, &CPlayer::SetControllable) + .Prop(_SC("driveby"), &CPlayer::GetDriveby, &CPlayer::SetDriveby) + .Prop(_SC("white_scanlines"), &CPlayer::GetWhiteScanlines, &CPlayer::SetWhiteScanlines) + .Prop(_SC("green_scanlines"), &CPlayer::GetGreenScanlines, &CPlayer::SetGreenScanlines) + .Prop(_SC("widescreen"), &CPlayer::GetWidescreen, &CPlayer::SetWidescreen) + .Prop(_SC("show_markers"), &CPlayer::GetShowMarkers, &CPlayer::SetShowMarkers) + .Prop(_SC("attack_priv"), &CPlayer::GetAttackPriv, &CPlayer::SetAttackPriv) + .Prop(_SC("has_marker"), &CPlayer::GetHasMarker, &CPlayer::SetHasMarker) + .Prop(_SC("chat_tags"), &CPlayer::GetChatTags, &CPlayer::SetChatTags) + .Prop(_SC("drunk_effects"), &CPlayer::GetDrunkEffects, &CPlayer::SetDrunkEffects) + .Prop(_SC("weapon"), &CPlayer::GetWeapon, &CPlayer::SetWeapon) + .Prop(_SC("weapon_id"), &CPlayer::GetWeaponID, &CPlayer::SetWeaponID) + .Prop(_SC("camera_locked"), &CPlayer::IsCameraLocked) + .Prop(_SC("wanted_level"), &CPlayer::GetWantedLevel, &CPlayer::SetWantedLevel) + .Prop(_SC("touched_vehicle"), &CPlayer::StandingOnVehicle) + .Prop(_SC("touched_object"), &CPlayer::StandingOnObject, &CPlayer::Spectate) + .Prop(_SC("away"), &CPlayer::IsAway) + .Prop(_SC("spectating"), &CPlayer::Spectating) + .Prop(_SC("crouched"), &CPlayer::IsCrouched) + .Prop(_SC("game_keys"), &CPlayer::GetGameKeys) + .Prop(_SC("aim_pos"), &CPlayer::GetAimPos) + .Prop(_SC("aim_position"), &CPlayer::GetAimPos) + .Prop(_SC("aim_dir"), &CPlayer::GetAimDir) + .Prop(_SC("aim_direction"), &CPlayer::GetAimDir) + /* Functions */ + .Func(_SC("streamed_for"), &CPlayer::IsStreamedFor) + .Func(_SC("kick"), &CPlayer::Kick) + .Func(_SC("ban"), &CPlayer::Ban) + .Func(_SC("world_compatible"), &CPlayer::IsWorldCompatible) + .Func(_SC("set_color"), &CPlayer::SetColorEx) + .Func(_SC("spawn"), &CPlayer::ForceSpawn) + .Func(_SC("select"), &CPlayer::ForceSelect) + .Func(_SC("give_money"), &CPlayer::GiveMoney) + .Func(_SC("set_position"), &CPlayer::SetPositionEx) + .Func(_SC("set_pos"), &CPlayer::SetPositionEx) + .Func(_SC("set_speed"), &CPlayer::SetSpeedEx) + .Func(_SC("set_weapon"), &CPlayer::SetWeaponEx) + .Func(_SC("set_weapon_id"), &CPlayer::SetWeaponIDEx) + .Func(_SC("give_weapon_id"), &CPlayer::GiveWeaponIDEx) + .Func(_SC("strip_weapons"), &CPlayer::StripWeapons) + .Func(_SC("camera_position"), &CPlayer::SetCameraPosition) + .Func(_SC("restore_camera"), &CPlayer::RestoreCamera) + .Func(_SC("animation"), &CPlayer::SetAnimation) + .Func(_SC("spectate"), &CPlayer::Spectate) + .Func(_SC("disembark"), &CPlayer::Disembark) + .Func(_SC("redirect"), &CPlayer::Redirect) + /* Overloads */ + .Overload< void (CPlayer::*)(const Vector3 &) const > + (_SC("add_speed"), &CPlayer::AddSpeed) + .Overload< void (CPlayer::*)(SQFloat, SQFloat, SQFloat) const > + (_SC("add_speed"), &CPlayer::AddSpeedEx) + .Overload< void (CPlayer::*)(const CWeapon &) const > + (_SC("give_weapon"), &CPlayer::GiveWeapon) + .Overload< void (CPlayer::*)(const CWeapon &, SQInt32) const > + (_SC("give_weapon"), &CPlayer::GiveWeaponEx) + .Overload< void (CPlayer::*)(const Reference < CVehicle > &) const > + (_SC("embark"), &CPlayer::Embark) + .Overload< void (CPlayer::*)(const Reference < CVehicle > &, SQInt32, bool, bool) const > + (_SC("embark"), &CPlayer::Embark) ); - + // Output debugging information LogDbg("Registration of type was successful"); - + // Registration succeeded return true; } diff --git a/source/Entity/Player.hpp b/source/Entity/Player.hpp index 641b5226..8a017d80 100644 --- a/source/Entity/Player.hpp +++ b/source/Entity/Player.hpp @@ -8,13 +8,593 @@ namespace SqMod { /* ------------------------------------------------------------------------------------------------ - * ... + * Class responsible for managing the referenced player instance. */ class CPlayer : public Reference< CPlayer > { -public: // -------------------------------------------------------------------------------------------- + static CSkin s_Skin; + static CWeapon s_Weapon; + + // -------------------------------------------------------------------------------------------- + static Color3 s_Color3; + static Vector3 s_Vector3; + + // -------------------------------------------------------------------------------------------- + static SQChar s_Buffer[128]; + +public: + + /* -------------------------------------------------------------------------------------------- + * Import the constructors, destructors and assignment operators from the base class. + */ using RefType::Reference; + + /* -------------------------------------------------------------------------------------------- + * See if the referenced player instance is streamed for the specified player. + */ + bool IsStreamedFor(const Reference < CPlayer > & player) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the class of the referenced player instance. + */ + SQInt32 GetClass() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has administrator privileges. + */ + bool GetAdmin() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has administrator privileges. + */ + void SetAdmin(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the ip address of the referenced player instance. + */ + const SQChar * GetIP() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Kick the referenced player instance from the server. + */ + void Kick() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Ban the referenced player instance from the server. + */ + void Ban() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is connected. + */ + bool IsConnected() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is spawned. + */ + bool IsSpawned() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the key of the referenced player instance. + */ + SQUnsignedInteger GetKey() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the world in which the referenced player instance exists. + */ + SQInt32 GetWorld() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the world in which the referenced player instance exists. + */ + void SetWorld(SQInt32 world) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the secondary world of the referenced player instance. + */ + SQInt32 GetSecWorld() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the secondary world of the referenced player instance. + */ + void SetSecWorld(SQInt32 world) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the unique world of the referenced player instance. + */ + SQInt32 GetUniqueWorld() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is compatible with the specified world. + */ + bool IsWorldCompatible(SQInt32 world) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the current state of the referenced player instance. + */ + SQInt32 GetState() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the nick name of the referenced player instance. + */ + const SQChar * GetName() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the nick name of the referenced player instance. + */ + void SetName(const SQChar * name) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the team of the referenced player instance. + */ + SQInt32 GetTeam() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the team of the referenced player instance. + */ + void SetTeam(SQInt32 team) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the skin of the referenced player instance. + */ + const CSkin & GetSkin() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the skin of the referenced player instance. + */ + void SetSkin(const CSkin & skin) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the skin identifier of the referenced player instance. + */ + SQInt32 GetSkinID() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the skin identifier of the referenced player instance. + */ + void SetSkinID(SQInt32 skin) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the color of the referenced player instance. + */ + const Color3 & GetColor() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the color of the referenced player instance. + */ + void SetColor(const Color3 & color) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the color of the referenced player instance. + */ + void SetColorEx(uint8 r, uint8 g, uint8 b) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Force the referenced player instance to spawn in the game. + */ + void ForceSpawn() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Force the referenced player instance to select a class. + */ + void ForceSelect() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the money amount of the referenced player instance. + */ + SQInt32 GetMoney() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the money amount of the referenced player instance. + */ + void SetMoney(SQInt32 amount) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Give a certain amount of money to the referenced player instance. + */ + void GiveMoney(SQInt32 amount) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the score of the referenced player instance. + */ + SQInt32 GetScore() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the score of the referenced player instance. + */ + void SetScore(SQInt32 score) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the connection latency of the referenced player instance. + */ + SQInt32 GetPing() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the frames per second of the referenced player instance. + */ + SQFloat GetFPS() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is typing. + */ + bool IsTyping() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the unique user identifier of the referenced player instance. + */ + const SQChar * GetUID() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the unique user identifier version 2 of the referenced player instance. + */ + const SQChar * GetUID2() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the current health of the referenced player instance. + */ + SQFloat GetHealth() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the health of the referenced player instance. + */ + void SetHealth(SQFloat amount) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the current health of the referenced player instance. + */ + SQFloat GetArmour() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the health of the referenced player instance. + */ + void SetArmour(SQFloat amount) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the immunity flags of the referenced player instance. + */ + SQInt32 GetImmunity() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the immunity flags of the referenced player instance. + */ + void SetImmunity(SQInt32 flags) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the position of the referenced player instance. + */ + const Vector3 & GetPosition() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the position of the referenced player instance. + */ + void SetPosition(const Vector3 & pos) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the position of the referenced player instance. + */ + void SetPositionEx(SQFloat x, SQFloat y, SQFloat z) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the speed of the referenced player instance. + */ + const Vector3 & GetSpeed() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the speed of the referenced player instance. + */ + void SetSpeed(const Vector3 & vel) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the speed of the referenced player instance. + */ + void SetSpeedEx(SQFloat x, SQFloat y, SQFloat z) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the speed of the referenced player instance. + */ + void AddSpeed(const Vector3 & vel) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the speed of the referenced player instance. + */ + void AddSpeedEx(SQFloat x, SQFloat y, SQFloat z) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the heading angle of the referenced player instance. + */ + SQFloat GetHeading() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the heading angle of the referenced player instance. + */ + void SetHeading(SQFloat angle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the alpha of the referenced player instance. + */ + SQInt32 GetAlpha() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the alpha of the referenced player instance. + */ + void SetAlpha(SQInt32 alpha, SQInt32 fade) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the vehicle status of the referenced player instance. + */ + SQInt32 GetVehicleStatus() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the occupied vehicle slot by the referenced player instance. + */ + SQInt32 GetOccupiedSlot() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the vehicle in which the referenced player instance is embarked. + */ + Reference < CVehicle > GetVehicle() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the vehicle identifier in which the referenced player instance is embarked. + */ + SQInt32 GetVehicleID() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance can be controlled. + */ + bool GetControllable() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance can be controlled. + */ + void SetControllable(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance can driveby. + */ + bool GetDriveby() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance can driveby. + */ + void SetDriveby(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has white scanlines. + */ + bool GetWhiteScanlines() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has white scanlines. + */ + void SetWhiteScanlines(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has green scanlines. + */ + bool GetGreenScanlines() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has green scanlines. + */ + void SetGreenScanlines(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has widescreen. + */ + bool GetWidescreen() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has widescreen. + */ + void SetWidescreen(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance displays markers. + */ + bool GetShowMarkers() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance displays markers. + */ + void SetShowMarkers(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has attacking privileges. + */ + bool GetAttackPriv() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has attacking privileges. + */ + void SetAttackPriv(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has markers. + */ + bool GetHasMarker() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has markers. + */ + void SetHasMarker(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has chat tags. + */ + bool GetChatTags() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance has chat tags. + */ + void SetChatTags(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is under drunk effects. + */ + bool GetDrunkEffects() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set whether the referenced player instance is under drunk effects. + */ + void SetDrunkEffects(bool toggle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the weapon of the referenced player instance. + */ + const CWeapon & GetWeapon() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the weapon of the referenced player instance. + */ + void SetWeapon(const CWeapon & wep) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the weapon of the referenced player instance. + */ + void SetWeaponEx(const CWeapon & wep, SQInt32 ammo) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the weapon identifier of the referenced player instance. + */ + SQInt32 GetWeaponID() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the weapon of the referenced player instance. + */ + void SetWeaponID(SQInt32 wep) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the weapon of the referenced player instance. + */ + void SetWeaponIDEx(SQInt32 wep, SQInt32 ammo) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Give a weapon of the referenced player instance. + */ + void GiveWeapon(const CWeapon & wep) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Give a weapon of the referenced player instance. + */ + void GiveWeaponEx(const CWeapon & wep, SQInt32 ammo) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Give a weapon of the referenced player instance. + */ + void GiveWeaponIDEx(SQInt32 wep, SQInt32 ammo) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Strip the referenced player instance of all weapons. + */ + void StripWeapons() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the camera position of the referenced player instance. + */ + void SetCameraPosition(const Vector3 & pos, const Vector3 & aim) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Restore the camera position of the referenced player instance. + */ + void RestoreCamera() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance has camera locked. + */ + bool IsCameraLocked() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the animation of the referenced player instance. + */ + void SetAnimation(SQInt32 group, SQInt32 anim) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the wanted level of the referenced player instance. + */ + SQInt32 GetWantedLevel() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Change the wanted level of the referenced player instance. + */ + void SetWantedLevel(SQInt32 level) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the vehicle that the referenced player instance is standing on. + */ + Reference < CVehicle > StandingOnVehicle() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the object that the referenced player instance is standing on. + */ + Reference < CObject > StandingOnObject() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is away. + */ + bool IsAway() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the player that the referenced player instance is spectating. + */ + Reference < CPlayer > Spectating() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Set the referenced player instance to spectate the specified player instance. + */ + void Spectate(const Reference < CPlayer > & target) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is burning. + */ + bool IsBurning() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * See whether the referenced player instance is crouched. + */ + bool IsCrouched() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the current action of the referenced player instance. + */ + SQInt32 GetAction() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the game keys of the referenced player instance. + */ + SQInt32 GetGameKeys() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the aim position of the referenced player instance. + */ + const Vector3 & GetAimPos() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Retrieve the aim direction of the referenced player instance. + */ + const Vector3 & GetAimDir() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Embark the referenced player instance into the specified vehicle instance. + */ + void Embark(const Reference < CVehicle > & vehicle) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Embark the referenced player instance into the specified vehicle instance. + */ + void Embark(const Reference < CVehicle > & vehicle, SQInt32 slot, bool allocate, bool warp) const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Disembark the referenced player instance from the currently embarked vehicle instance. + */ + void Disembark() const noexcept; + + /* -------------------------------------------------------------------------------------------- + * Redirect the referenced player instance to the specified server. + */ + bool Redirect(const SQChar * ip, SQUnsignedInteger port, const SQChar * nick, \ + const SQChar * pass, const SQChar * user) noexcept; }; } // Namespace:: SqMod