more player stats lua bindings (#3325)
get_player_money get_player_wallet get_player_bank get_player_language_id get_player_language_name
This commit is contained in:
parent
a341753748
commit
796f6209f5
@ -177,6 +177,9 @@ Call get_player_rank(playerID)
|
|||||||
- **Parameters:**
|
- **Parameters:**
|
||||||
- `pid` (int)
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players rank.
|
||||||
|
|
||||||
**Example Usage:**
|
**Example Usage:**
|
||||||
```lua
|
```lua
|
||||||
network.get_player_rank(pid)
|
network.get_player_rank(pid)
|
||||||
@ -189,9 +192,85 @@ Call get_player_rp(playerID)
|
|||||||
- **Parameters:**
|
- **Parameters:**
|
||||||
- `pid` (int)
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players rp.
|
||||||
|
|
||||||
**Example Usage:**
|
**Example Usage:**
|
||||||
```lua
|
```lua
|
||||||
network.get_player_rp(pid)
|
network.get_player_rp(pid)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `get_player_money(pid)`
|
||||||
|
|
||||||
|
Call get_player_money(playerID)
|
||||||
|
|
||||||
|
- **Parameters:**
|
||||||
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players money.
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
```lua
|
||||||
|
network.get_player_money(pid)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get_player_wallet(pid)`
|
||||||
|
|
||||||
|
Call get_player_wallet(playerID)
|
||||||
|
|
||||||
|
- **Parameters:**
|
||||||
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players wallet.
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
```lua
|
||||||
|
network.get_player_wallet(pid)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get_player_bank(pid)`
|
||||||
|
|
||||||
|
Call get_player_bank(playerID)
|
||||||
|
|
||||||
|
- **Parameters:**
|
||||||
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players bank.
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
```lua
|
||||||
|
network.get_player_bank(pid)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get_player_language_id(pid)`
|
||||||
|
|
||||||
|
Call get_player_language_id(playerID)
|
||||||
|
|
||||||
|
- **Parameters:**
|
||||||
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `int`: Returns an integer which contains the players language id.
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
```lua
|
||||||
|
network.get_player_language_id(pid)
|
||||||
|
```
|
||||||
|
|
||||||
|
### `get_player_language_name(pid)`
|
||||||
|
|
||||||
|
Call get_player_language_name(playerID)
|
||||||
|
|
||||||
|
- **Parameters:**
|
||||||
|
- `pid` (int)
|
||||||
|
|
||||||
|
- **Returns:**
|
||||||
|
- `string`: Returns a string which contains the players language name.
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
```lua
|
||||||
|
network.get_player_language_name(pid)
|
||||||
|
```
|
@ -1,6 +1,7 @@
|
|||||||
#include "network.hpp"
|
#include "network.hpp"
|
||||||
|
|
||||||
#include "../../script.hpp"
|
#include "../../script.hpp"
|
||||||
|
#include "core/data/language_codes.hpp"
|
||||||
#include "core/scr_globals.hpp"
|
#include "core/scr_globals.hpp"
|
||||||
#include "hooking/hooking.hpp"
|
#include "hooking/hooking.hpp"
|
||||||
#include "pointers.hpp"
|
#include "pointers.hpp"
|
||||||
@ -12,6 +13,7 @@
|
|||||||
#include "util/system.hpp"
|
#include "util/system.hpp"
|
||||||
#include "util/teleport.hpp"
|
#include "util/teleport.hpp"
|
||||||
#include <script/globals/GPBD_FM.hpp>
|
#include <script/globals/GPBD_FM.hpp>
|
||||||
|
#include <script/globals/GPBD_FM_3.hpp>
|
||||||
|
|
||||||
namespace lua::network
|
namespace lua::network
|
||||||
{
|
{
|
||||||
@ -207,7 +209,7 @@ namespace lua::network
|
|||||||
// Lua API: Function
|
// Lua API: Function
|
||||||
// Table: network
|
// Table: network
|
||||||
// Name: get_player_rank
|
// Name: get_player_rank
|
||||||
// Param: pid: int
|
// Param: pid: integer: Index of the player.
|
||||||
// Call get_player_rank(playerID)
|
// Call get_player_rank(playerID)
|
||||||
static int get_player_rank(int pid)
|
static int get_player_rank(int pid)
|
||||||
{
|
{
|
||||||
@ -222,7 +224,7 @@ namespace lua::network
|
|||||||
// Lua API: Function
|
// Lua API: Function
|
||||||
// Table: network
|
// Table: network
|
||||||
// Name: get_player_rp
|
// Name: get_player_rp
|
||||||
// Param: pid: int
|
// Param: pid: integer: Index of the player.
|
||||||
// Call get_player_rp(playerID)
|
// Call get_player_rp(playerID)
|
||||||
static int get_player_rp(int pid)
|
static int get_player_rp(int pid)
|
||||||
{
|
{
|
||||||
@ -234,6 +236,81 @@ namespace lua::network
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Lua API: Function
|
||||||
|
// Table: network
|
||||||
|
// Name: get_player_money
|
||||||
|
// Param: pid: integer: Index of the player.
|
||||||
|
// Call get_player_money(playerID)
|
||||||
|
static int get_player_money(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.Money;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua API: Function
|
||||||
|
// Table: network
|
||||||
|
// Name: get_player_wallet
|
||||||
|
// Param: pid: integer: Index of the player.
|
||||||
|
// Call get_player_wallet(playerID)
|
||||||
|
static int get_player_wallet(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.WalletBalance;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua API: Function
|
||||||
|
// Table: network
|
||||||
|
// Name: get_player_bank
|
||||||
|
// Param: pid: integer: Index of the player.
|
||||||
|
// Call get_player_bank(playerID)
|
||||||
|
static int get_player_bank(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.Money - stats.WalletBalance;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua API: Function
|
||||||
|
// Table: network
|
||||||
|
// Name: get_player_language_id
|
||||||
|
// Param: pid: integer: Index of the player.
|
||||||
|
// Call get_player_language_id(playerID)
|
||||||
|
static int get_player_language_id(int pid)
|
||||||
|
{
|
||||||
|
if (big::g_player_service->get_by_id(pid))
|
||||||
|
{
|
||||||
|
auto& boss_goon = big::scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[pid].BossGoon;
|
||||||
|
return boss_goon.Language;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lua API: Function
|
||||||
|
// Table: network
|
||||||
|
// Name: get_player_language_name
|
||||||
|
// Param: pid: integer: Index of the player.
|
||||||
|
// Call get_player_language_name(playerID)
|
||||||
|
static std::string get_player_language_name(int pid)
|
||||||
|
{
|
||||||
|
if (big::g_player_service->get_by_id(pid))
|
||||||
|
{
|
||||||
|
auto& boss_goon = big::scr_globals::gpbd_fm_3.as<GPBD_FM_3*>()->Entries[pid].BossGoon;
|
||||||
|
return big::languages[boss_goon.Language].name;
|
||||||
|
}
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
|
||||||
void bind(sol::state& state)
|
void bind(sol::state& state)
|
||||||
{
|
{
|
||||||
state.new_enum<big::Infraction>("infraction",
|
state.new_enum<big::Infraction>("infraction",
|
||||||
@ -275,5 +352,10 @@ namespace lua::network
|
|||||||
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_rank"] = get_player_rank;
|
||||||
ns["get_player_rp"] = get_player_rp;
|
ns["get_player_rp"] = get_player_rp;
|
||||||
|
ns["get_player_money"] = get_player_money;
|
||||||
|
ns["get_player_wallet"] = get_player_wallet;
|
||||||
|
ns["get_player_bank"] = get_player_bank;
|
||||||
|
ns["get_player_language_id"] = get_player_language_id;
|
||||||
|
ns["get_player_language_name"] = get_player_language_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user