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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 63 additions and 4 deletions

View File

@ -7,8 +7,9 @@ All the infraction from the menu are listed below, used as parameter for adding
network.flag_player_as_modder(player_index, infraction.CUSTOM_REASON, "My custom reason on why the player is flagged as a modder") network.flag_player_as_modder(player_index, infraction.CUSTOM_REASON, "My custom reason on why the player is flagged as a modder")
``` ```
## Infraction Count: 12 ## Infraction Count: 13
### `DESYNC_PROTECTION`
### `TRIGGERED_ANTICHEAT` ### `TRIGGERED_ANTICHEAT`
### `TRIED_CRASH_PLAYER` ### `TRIED_CRASH_PLAYER`
### `TRIED_KICK_PLAYER` ### `TRIED_KICK_PLAYER`

View File

@ -2,7 +2,7 @@
Table containing helper functions for network related features. Table containing helper functions for network related features.
## Functions (13) ## Functions (15)
### `trigger_script_event(bitset, _args)` ### `trigger_script_event(bitset, _args)`
@ -170,4 +170,28 @@ Sends a chat message to the specified player. Other players would not be able to
network.send_chat_message_to_player(player_idx, msg) network.send_chat_message_to_player(player_idx, msg)
``` ```
### `get_player_rank(pid)`
Call get_player_rank(playerID)
- **Parameters:**
- `pid` (int)
**Example Usage:**
```lua
network.get_player_rank(pid)
```
### `get_player_rp(pid)`
Call get_player_rp(playerID)
- **Parameters:**
- `pid` (int)
**Example Usage:**
```lua
network.get_player_rp(pid)
```

View File

@ -1,15 +1,17 @@
#include "network.hpp" #include "network.hpp"
#include "../../script.hpp" #include "../../script.hpp"
#include "core/scr_globals.hpp"
#include "hooking/hooking.hpp" #include "hooking/hooking.hpp"
#include "pointers.hpp" #include "pointers.hpp"
#include "services/player_database/player_database_service.hpp" #include "services/player_database/player_database_service.hpp"
#include "util/notify.hpp"
#include "util/chat.hpp" #include "util/chat.hpp"
#include "util/notify.hpp"
#include "util/scripts.hpp" #include "util/scripts.hpp"
#include "util/session.hpp" #include "util/session.hpp"
#include "util/system.hpp" #include "util/system.hpp"
#include "util/teleport.hpp" #include "util/teleport.hpp"
#include <script/globals/GPBD_FM.hpp>
namespace lua::network 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) void bind(sol::state& state)
{ {
state.new_enum<big::Infraction>("infraction", state.new_enum<big::Infraction>("infraction",
@ -241,5 +273,7 @@ namespace lua::network
ns["force_script_host"] = force_script_host; ns["force_script_host"] = force_script_host;
ns["send_chat_message"] = send_chat_message; ns["send_chat_message"] = send_chat_message;
ns["send_chat_message_to_player"] = send_chat_message_to_player; 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;
} }
} }