#include "Entity/Player.hpp" #include "Base/Color3.hpp" #include "Misc/Skin.hpp" #include "Misc/Weapon.hpp" #include "Register.hpp" // ------------------------------------------------------------------------------------------------ namespace SqMod { // ------------------------------------------------------------------------------------------------ CSkin CPlayer::s_Skin; CWeapon CPlayer::s_Weapon; // ------------------------------------------------------------------------------------------------ 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); } 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; } } // Namespace:: SqMod