Make Player Stats Retrievable Within Lua (#3199)
Some checks are pending
Nightly Build / Check Recent Commit (push) Successful in 34s
Nightly Build / Build Nightly (push) Waiting to run
Nightly Build / Recreate Release (push) Blocked by required conditions

This commit is contained in:
kikkin_yo_azzez
2024-06-01 05:57:21 -05:00
committed by GitHub
parent 9a2e85b7f5
commit 155ffebe11
3 changed files with 63 additions and 4 deletions

View File

@ -1,15 +1,17 @@
#include "network.hpp"
#include "../../script.hpp"
#include "core/scr_globals.hpp"
#include "hooking/hooking.hpp"
#include "pointers.hpp"
#include "services/player_database/player_database_service.hpp"
#include "util/notify.hpp"
#include "util/chat.hpp"
#include "util/notify.hpp"
#include "util/scripts.hpp"
#include "util/session.hpp"
#include "util/system.hpp"
#include "util/teleport.hpp"
#include <script/globals/GPBD_FM.hpp>
namespace lua::network
{
@ -202,6 +204,36 @@ namespace lua::network
}
}
// Lua API: Function
// Table: network
// Name: get_player_rank
// Param: pid: int
// Call get_player_rank(playerID)
static int get_player_rank(int pid)
{
if (big::g_player_service->get_by_id(pid))
{
auto& stats = big::scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[pid].PlayerStats;
return stats.Rank;
}
return -1;
}
// Lua API: Function
// Table: network
// Name: get_player_rp
// Param: pid: int
// Call get_player_rp(playerID)
static int get_player_rp(int pid)
{
if (big::g_player_service->get_by_id(pid))
{
auto& stats = big::scr_globals::gpbd_fm_1.as<GPBD_FM*>()->Entries[pid].PlayerStats;
return stats.RP;
}
return -1;
}
void bind(sol::state& state)
{
state.new_enum<big::Infraction>("infraction",
@ -241,5 +273,7 @@ namespace lua::network
ns["force_script_host"] = force_script_host;
ns["send_chat_message"] = send_chat_message;
ns["send_chat_message_to_player"] = send_chat_message_to_player;
ns["get_player_rank"] = get_player_rank;
ns["get_player_rp"] = get_player_rp;
}
}
}