Make Player Stats Retrievable Within Lua (#3199)
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user