mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Make Player Stats Retrievable Within Lua (#3199)
This commit is contained in:
parent
9baaf42b79
commit
0e7b5c1d37
@ -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")
|
||||
```
|
||||
|
||||
## Infraction Count: 12
|
||||
## Infraction Count: 13
|
||||
|
||||
### `DESYNC_PROTECTION`
|
||||
### `TRIGGERED_ANTICHEAT`
|
||||
### `TRIED_CRASH_PLAYER`
|
||||
### `TRIED_KICK_PLAYER`
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
Table containing helper functions for network related features.
|
||||
|
||||
## Functions (13)
|
||||
## Functions (15)
|
||||
|
||||
### `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)
|
||||
```
|
||||
|
||||
### `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)
|
||||
```
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user