2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _ENTITY_PLAYER_HPP_
|
|
|
|
#define _ENTITY_PLAYER_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Shared.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Manages Player instances.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
class CPlayer
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
friend class Core;
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
private:
|
2015-10-29 21:11:30 +01:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
static Color3 s_Color3;
|
|
|
|
static Vector3 s_Vector3;
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static SQChar s_Buffer[SQMOD_PLAYER_TMP_BUFFER];
|
2015-10-29 21:11:30 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Cached identifiers for fast integer to string conversion.
|
2015-11-01 00:32:41 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
static SQChar s_StrID[SQMOD_PLAYER_POOL][8];
|
2015-11-01 00:32:41 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Identifier of the managed entity.
|
2015-11-07 11:17:39 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 m_ID;
|
2015-11-07 11:17:39 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* User tag and data associated with this instance.
|
2015-11-07 11:17:39 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
String m_Tag;
|
|
|
|
Object m_Data;
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Base constructor.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CPlayer(Int32 id);
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Copy constructor. (disabled)
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CPlayer(const CPlayer &);
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Copy assignment operator. (disabled)
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CPlayer & operator = (const CPlayer &);
|
2015-11-09 04:54:03 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
public:
|
2015-11-09 04:54:03 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
static const Int32 Max;
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Destructor.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
~CPlayer();
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* See whether this instance manages a valid entity.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Validate() const
|
|
|
|
{
|
|
|
|
if (VALID_ENTITY(m_ID))
|
|
|
|
return true;
|
|
|
|
SqThrow("Invalid player reference [%s]", m_Tag.c_str());
|
|
|
|
return false;
|
|
|
|
}
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const CPlayer & o) const;
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr ToString() const;
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetID() const { return m_ID; }
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the maximum possible identifier to an entity of this type.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetMaxID() const { return SQMOD_PLAYER_POOL; }
|
2015-11-09 04:54:03 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Check whether this instance manages a valid entity.
|
2015-11-09 04:54:03 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool IsActive() const { return VALID_ENTITY(m_ID); }
|
2015-11-07 11:17:39 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user tag.
|
2015-10-29 21:11:30 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr GetTag() const;
|
2015-10-29 21:11:30 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user tag.
|
2015-10-29 21:11:30 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetTag(CSStr tag);
|
2015-10-29 21:11:30 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user data.
|
2015-10-29 21:11:30 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetData();
|
2015-10-29 21:11:30 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user data.
|
2015-10-29 21:11:30 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetData(Object & data);
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool BindEvent(Int32 evid, Object & env, Function & func) const;
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
bool IsStreamedFor(CPlayer & player) const;
|
|
|
|
Int32 GetClass() const;
|
|
|
|
bool GetAdmin() const;
|
|
|
|
void SetAdmin(bool toggle) const;
|
|
|
|
CSStr GetIP() const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void Kick() const;
|
|
|
|
void Ban() const;
|
|
|
|
bool IsConnected() const;
|
|
|
|
bool IsSpawned() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint32 GetKey() const;
|
|
|
|
Int32 GetWorld() const;
|
|
|
|
void SetWorld(Int32 world) const;
|
|
|
|
Int32 GetSecWorld() const;
|
|
|
|
void SetSecWorld(Int32 world) const;
|
|
|
|
Int32 GetUniqueWorld() const;
|
|
|
|
bool IsWorldCompatible(Int32 world) const;
|
|
|
|
CSStr GetName() const;
|
|
|
|
void SetName(CSStr name) const;
|
|
|
|
Int32 GetTeam() const;
|
|
|
|
void SetTeam(Int32 team) const;
|
|
|
|
Int32 GetSkin() const;
|
|
|
|
void SetSkin(Int32 skin) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
const Color3 & GetColor() const;
|
|
|
|
void SetColor(const Color3 & color) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorEx(Uint8 r, Uint8 g, Uint8 b) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void ForceSpawn() const;
|
|
|
|
void ForceSelect() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetMoney() const;
|
|
|
|
void SetMoney(Int32 amount) const;
|
|
|
|
void GiveMoney(Int32 amount) const;
|
|
|
|
Int32 GetScore() const;
|
|
|
|
void SetScore(Int32 score) const;
|
|
|
|
Int32 GetPing() const;
|
|
|
|
Float32 GetFPS() const;
|
2015-11-01 04:48:01 +01:00
|
|
|
bool IsTyping() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
CSStr GetUID() const;
|
|
|
|
CSStr GetUID2() const;
|
|
|
|
Float32 GetHealth() const;
|
|
|
|
void SetHealth(Float32 amount) const;
|
|
|
|
Float32 GetArmor() const;
|
|
|
|
void SetArmor(Float32 amount) const;
|
|
|
|
Int32 GetImmunity() const;
|
|
|
|
void SetImmunity(Int32 flags) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
const Vector3 & GetPosition() const;
|
|
|
|
void SetPosition(const Vector3 & pos) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionEx(Float32 x, Float32 y, Float32 z) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
const Vector3 & GetSpeed() const;
|
|
|
|
void SetSpeed(const Vector3 & vel) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetSpeedEx(Float32 x, Float32 y, Float32 z) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void AddSpeed(const Vector3 & vel) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void AddSpeedEx(Float32 x, Float32 y, Float32 z) const;
|
|
|
|
Float32 GetHeading() const;
|
|
|
|
void SetHeading(Float32 angle) const;
|
|
|
|
Int32 GetAlpha() const;
|
|
|
|
void SetAlpha(Int32 alpha, Int32 fade) const;
|
|
|
|
Int32 GetVehicleStatus() const;
|
|
|
|
Int32 GetOccupiedSlot() const;
|
|
|
|
Object & GetVehicle() const;
|
|
|
|
Int32 GetVehicleID() const;
|
2015-11-01 04:48:01 +01:00
|
|
|
bool GetControllable() const;
|
|
|
|
void SetControllable(bool toggle) const;
|
|
|
|
bool GetDriveby() const;
|
|
|
|
void SetDriveby(bool toggle) const;
|
|
|
|
bool GetWhiteScanlines() const;
|
|
|
|
void SetWhiteScanlines(bool toggle) const;
|
|
|
|
bool GetGreenScanlines() const;
|
|
|
|
void SetGreenScanlines(bool toggle) const;
|
|
|
|
bool GetWidescreen() const;
|
|
|
|
void SetWidescreen(bool toggle) const;
|
|
|
|
bool GetShowMarkers() const;
|
|
|
|
void SetShowMarkers(bool toggle) const;
|
|
|
|
bool GetAttackPriv() const;
|
|
|
|
void SetAttackPriv(bool toggle) const;
|
|
|
|
bool GetHasMarker() const;
|
|
|
|
void SetHasMarker(bool toggle) const;
|
|
|
|
bool GetChatTags() const;
|
|
|
|
void SetChatTags(bool toggle) const;
|
|
|
|
bool GetDrunkEffects() const;
|
|
|
|
void SetDrunkEffects(bool toggle) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetWeapon() const;
|
|
|
|
void SetWeapon(Int32 wep, Int32 ammo) const;
|
|
|
|
void GiveWeapon(Int32 wep, Int32 ammo) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void StripWeapons() const;
|
|
|
|
void SetCameraPosition(const Vector3 & pos, const Vector3 & aim) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetCameraPosition(Float32 xp, Float32 yp, Float32 zp, Float32 xa, Float32 ya, Float32 za) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void RestoreCamera() const;
|
|
|
|
bool IsCameraLocked() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetAnimation(Int32 group, Int32 anim) const;
|
|
|
|
Int32 GetWantedLevel() const;
|
|
|
|
void SetWantedLevel(Int32 level) const;
|
|
|
|
Object & StandingOnVehicle() const;
|
|
|
|
Object & StandingOnObject() const;
|
2015-11-01 04:48:01 +01:00
|
|
|
bool IsAway() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetSpectator() const;
|
|
|
|
void SetSpectator(CPlayer & target) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
bool IsBurning() const;
|
|
|
|
bool IsCrouched() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 GetState() const;
|
|
|
|
Int32 GetAction() const;
|
|
|
|
Int32 GetGameKeys() const;
|
2015-11-01 04:48:01 +01:00
|
|
|
const Vector3 & GetAimPos() const;
|
|
|
|
const Vector3 & GetAimDir() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
void Embark(CVehicle & vehicle) const;
|
|
|
|
void Embark(CVehicle & vehicle, Int32 slot, bool allocate, bool warp) const;
|
2015-11-01 04:48:01 +01:00
|
|
|
void Disembark() const;
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Redirect(CSStr ip, Uint32 port, CSStr nick, CSStr pass, CSStr user);
|
|
|
|
Int32 GetAuthority() const;
|
|
|
|
void SetAuthority(Int32 level) const;
|
|
|
|
CSStr GetMessagePrefix(Uint32 index) const;
|
|
|
|
void SetMessagePrefix(Uint32 index, CSStr prefix) const;
|
|
|
|
Uint32 GetMessageColor() const;
|
|
|
|
void SetMessageColor(Uint32 color) const;
|
|
|
|
Int32 GetAnnounceStyle() const;
|
|
|
|
void SetAnnounceStyle(Int32 style) const;
|
2015-10-29 21:11:30 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
Float32 GetPosX() const;
|
|
|
|
Float32 GetPosY() const;
|
|
|
|
Float32 GetPosZ() const;
|
|
|
|
void SetPosX(Float32 x) const;
|
|
|
|
void SetPosY(Float32 y) const;
|
|
|
|
void SetPosZ(Float32 z) const;
|
2015-11-09 02:29:04 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
2015-11-09 02:29:04 +01:00
|
|
|
static SQInteger Msg(HSQUIRRELVM vm);
|
2015-11-09 03:32:32 +01:00
|
|
|
static SQInteger MsgP(HSQUIRRELVM vm);
|
2015-11-09 02:29:04 +01:00
|
|
|
static SQInteger MsgEx(HSQUIRRELVM vm);
|
|
|
|
static SQInteger Message(HSQUIRRELVM vm);
|
|
|
|
static SQInteger Announce(HSQUIRRELVM vm);
|
|
|
|
static SQInteger AnnounceEx(HSQUIRRELVM vm);
|
2015-11-09 04:54:03 +01:00
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
#endif // _ENTITY_PLAYER_HPP_
|