mirror of
https://github.com/ytsodacan/Faucet.git
synced 2026-04-23 07:28:07 +00:00
added player states and info and stats
This commit is contained in:
parent
365b3b084e
commit
8e0b047d33
|
|
@ -112,6 +112,72 @@ PlayerPos SDK::GetPlayerPos(int index) {
|
|||
return { p->x, p->y, p->z };
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Player Stats
|
||||
// ============================================================================
|
||||
|
||||
float SDK::GetPlayerHealth(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->getHealth() : 0.0f;
|
||||
}
|
||||
|
||||
void SDK::SetPlayerHealth(float health, int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
if (!p) return;
|
||||
// Clamp to valid range so modders can't accidentally set 999 hp
|
||||
if (health < 0.0f) health = 0.0f;
|
||||
if (health > p->getMaxHealth()) health = p->getMaxHealth();
|
||||
p->setHealth(health);
|
||||
}
|
||||
|
||||
float SDK::GetPlayerMaxHealth(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->getMaxHealth() : 20.0f;
|
||||
}
|
||||
|
||||
bool SDK::IsPlayerAlive(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->getHealth() > 0.0f : false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Player State
|
||||
// ============================================================================
|
||||
|
||||
void SDK::SetPlayerFlying(bool flying, int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
if (p) p->abilities.flying = flying;
|
||||
}
|
||||
|
||||
bool SDK::IsPlayerFlying(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->abilities.flying : false;
|
||||
}
|
||||
|
||||
bool SDK::IsPlayerSprinting(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->isSprinting() : false;
|
||||
}
|
||||
|
||||
bool SDK::IsPlayerSneaking(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->isSneaking() : false;
|
||||
}
|
||||
|
||||
bool SDK::IsPlayerOnGround(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->onGround : false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Player Info
|
||||
// ============================================================================
|
||||
|
||||
std::wstring SDK::GetPlayerName(int index) {
|
||||
auto* p = GetLocalPlayer(index);
|
||||
return p ? p->name : L"";
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Messaging
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -42,6 +42,22 @@ namespace SDK {
|
|||
MODAPI double GetPlayerZ(int index = 0);
|
||||
MODAPI PlayerPos GetPlayerPos(int index = 0);
|
||||
|
||||
// Player Stats
|
||||
MODAPI float GetPlayerHealth(int index = 0);
|
||||
MODAPI void SetPlayerHealth(float health, int index = 0);
|
||||
MODAPI float GetPlayerMaxHealth(int index = 0);
|
||||
MODAPI bool IsPlayerAlive(int index = 0);
|
||||
|
||||
// Player State
|
||||
MODAPI void SetPlayerFlying(bool flying, int index = 0);
|
||||
MODAPI bool IsPlayerFlying(int index = 0);
|
||||
MODAPI bool IsPlayerSprinting(int index = 0);
|
||||
MODAPI bool IsPlayerSneaking(int index = 0);
|
||||
MODAPI bool IsPlayerOnGround(int index = 0);
|
||||
|
||||
// Player Info
|
||||
MODAPI std::wstring GetPlayerName(int index = 0);
|
||||
|
||||
// Messaging
|
||||
MODAPI void BroadcastMessage(const std::wstring& message);
|
||||
MODAPI void SendMessageToPlayer(const std::wstring& playerName, const std::wstring& message);
|
||||
|
|
|
|||
Loading…
Reference in a new issue