Skip to content

Commit d97c227

Browse files
committed
fix: fix economy related events
1 parent ac61608 commit d97c227

File tree

9 files changed

+25
-28
lines changed

9 files changed

+25
-28
lines changed

src/legacy/api/EventAPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ void InitBasicEventListeners() {
938938
});
939939
}
940940

941-
bool MoneyBeforeEventCallback(LLMoneyEvent type, xuid_t from, xuid_t to, money_t value) {
941+
bool MoneyBeforeEventCallback(LLMoneyEvent type, std::string from, std::string to, long long value) {
942942
switch (type) {
943943
case LLMoneyEvent::Add: {
944944
IF_LISTENED(EVENT_TYPES::beforeMoneyAdd) {
@@ -980,7 +980,7 @@ bool MoneyBeforeEventCallback(LLMoneyEvent type, xuid_t from, xuid_t to, money_t
980980
return true;
981981
}
982982

983-
bool MoneyEventCallback(LLMoneyEvent type, xuid_t from, xuid_t to, money_t value) {
983+
bool MoneyEventCallback(LLMoneyEvent type, std::string from, std::string to, long long value) {
984984
switch (type) {
985985
case LLMoneyEvent::Add: {
986986
IF_LISTENED(EVENT_TYPES::onMoneyAdd) {

src/legacy/api/EventAPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ bool LLSECallEventsOnHotUnload(ScriptEngine* engine);
1414

1515
//////////////////// Callback ////////////////////
1616

17-
bool MoneyBeforeEventCallback(LLMoneyEvent type, xuid_t from, xuid_t to, money_t value);
18-
bool MoneyEventCallback(LLMoneyEvent type, xuid_t from, xuid_t to, money_t value);
17+
bool MoneyBeforeEventCallback(LLMoneyEvent type, std::string from, std::string to, long long value);
18+
bool MoneyEventCallback(LLMoneyEvent type, std::string from, std::string to, long long value);
1919

2020
enum class EVENT_TYPES : int {
2121
/* Player Events */

src/legacy/main/EconomicSystem.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
#include <string>
55

66
using std::string;
7-
8-
typedef long long money_t;
9-
typedef std::string xuid_t;
10-
117
class EconomySystem {
128
public:
139
static bool init();
1410

15-
static money_t getMoney(xuid_t player);
16-
static bool setMoney(xuid_t player, money_t money);
17-
static bool addMoney(xuid_t player, money_t money);
18-
static bool reduceMoney(xuid_t player, money_t money);
19-
static bool transMoney(xuid_t player1, xuid_t player2, money_t money, string const& notes);
20-
static std::string getMoneyHist(xuid_t player, int time);
11+
static long long getMoney(std::string player);
12+
static bool setMoney(std::string player, long long money);
13+
static bool addMoney(std::string player, long long money);
14+
static bool reduceMoney(std::string player, long long money);
15+
static bool transMoney(std::string player1, std::string player2, long long money, string const& notes);
16+
static std::string getMoneyHist(std::string player, int time);
2117
static void clearMoneyHist(int time);
2218
};

src/legacy/main/EconomySystem.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,25 @@ ll::Logger economicLogger("EconomicSystem");
1111
////////////// Helper //////////////
1212

1313
bool EconomySystem::init() {
14-
// TODO
15-
// LLMoney_ListenBeforeEvent(MoneyBeforeEventCallback);
16-
// LLMoney_ListenAfterEvent(MoneyEventCallback);
14+
LLMoney_ListenBeforeEvent(MoneyBeforeEventCallback);
15+
LLMoney_ListenAfterEvent(MoneyEventCallback);
1716
return true;
1817
}
1918

20-
money_t EconomySystem::getMoney(xuid_t player) { return LLMoney_Get(player); }
19+
long long EconomySystem::getMoney(std::string player) { return LLMoney_Get(player); }
2120

22-
bool EconomySystem::setMoney(xuid_t player, money_t money) { return LLMoney_Set(player, money); }
21+
bool EconomySystem::setMoney(std::string player, long long money) { return LLMoney_Set(player, money); }
2322

24-
bool EconomySystem::addMoney(xuid_t player, money_t money) { return LLMoney_Set(player, LLMoney_Get(player) + money); }
23+
bool EconomySystem::addMoney(std::string player, long long money) {
24+
return LLMoney_Set(player, LLMoney_Get(player) + money);
25+
}
2526

26-
bool EconomySystem::reduceMoney(xuid_t player, money_t money) { return LLMoney_Reduce(player, money); }
27+
bool EconomySystem::reduceMoney(std::string player, long long money) { return LLMoney_Reduce(player, money); }
2728

28-
bool EconomySystem::transMoney(xuid_t player1, xuid_t player2, money_t money, string const& notes) {
29+
bool EconomySystem::transMoney(std::string player1, std::string player2, long long money, string const& notes) {
2930
return LLMoney_Trans(player1, player2, money, notes);
3031
}
3132

32-
std::string EconomySystem::getMoneyHist(xuid_t player, int time) { return LLMoney_GetHist(player, time); }
33+
std::string EconomySystem::getMoneyHist(std::string player, int time) { return LLMoney_GetHist(player, time); }
3334

3435
void EconomySystem::clearMoneyHist(int time) { LLMoney_ClearHist(time); }

tooth.lua.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"github.com/LiteLDev/LegacyRemoteCall": "0.4.x",
1616
"github.com/LiteLDev/LegacyParticleAPI": "0.4.x",
17-
"github.com/LiteLDev/LegacyMoney": "0.4.x"
17+
"github.com/LiteLDev/LegacyMoney": ">=0.4.1 <0.5.0"
1818
},
1919
"prerequisites": {
2020
"github.com/LiteLDev/LeviLamina": ">=0.9.3 <0.10.0"

tooth.nodejs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"github.com/LiteLDev/LegacyRemoteCall": "0.4.x",
1616
"github.com/LiteLDev/LegacyParticleAPI": "0.4.x",
17-
"github.com/LiteLDev/LegacyMoney": "0.4.x",
17+
"github.com/LiteLDev/LegacyMoney": ">=0.4.1 <0.5.0",
1818
"gitea.litebds.com/ShrBox/7-zip": "23.x",
1919
"gitea.litebds.com/LiteLDev/node-binaries": "16.16.0"
2020
},

tooth.python.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"github.com/LiteLDev/LegacyRemoteCall": "0.4.x",
1616
"github.com/LiteLDev/LegacyParticleAPI": "0.4.x",
17-
"github.com/LiteLDev/LegacyMoney": "0.4.x",
17+
"github.com/LiteLDev/LegacyMoney": ">=0.4.1 <0.5.0",
1818
"gitea.litebds.com/LiteLDev/python-binaries": "3.10.11"
1919
},
2020
"prerequisites": {

tooth.quickjs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"github.com/LiteLDev/LegacyRemoteCall": "0.4.x",
1616
"github.com/LiteLDev/LegacyParticleAPI": "0.4.x",
17-
"github.com/LiteLDev/LegacyMoney": "0.4.x"
17+
"github.com/LiteLDev/LegacyMoney": ">=0.4.1 <0.5.0"
1818
},
1919
"prerequisites": {
2020
"github.com/LiteLDev/LeviLamina": ">=0.9.3 <0.10.0"

xmake.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ add_requires(
66
"demangler",
77
"dyncall",
88
"fmt",
9-
"legacymoney 0.4.0",
9+
"legacymoney 0.4.1",
1010
"legacyparticleapi 0.4.0",
1111
"legacyremotecall 0.4.0",
1212
"levilamina 0.9.4",

0 commit comments

Comments
 (0)