-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmergencyManager.cpp
51 lines (40 loc) · 1.62 KB
/
EmergencyManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "EmergencyManager.h"
#include "Runtime.h"
namespace EmergencyManager {
Types::ChangePlayerScore ChangePlayerScore;
Types::ChangePlayerScore2 ChangePlayerScore2;
Types::Get Get;
int lChangePlayerScore(hks::lua_State* L) {
int argCount = hks::gettop(L);
Manager* manager = Get();
int playerId = hks::checkinteger(L, 1);
if (argCount == 3) {
int emergencyHash = hks::checkinteger(L, 2);
int amount = hks::checkinteger(L, 3);
ChangePlayerScore(manager, playerId, emergencyHash, amount);
}
else if (argCount == 4) {
int otherPlayerId = hks::checkinteger(L, 2);
int emergencyIndex = hks::checkinteger(L, 3);
int amount = hks::checkinteger(L, 4);
ChangePlayerScore2(manager, playerId, otherPlayerId, emergencyIndex, amount);
}
else {
hks::error(L, "Incorrect number of arguments. Expected 3 or 4.");
}
return 0;
}
int Register(hks::lua_State* L) {
std::cout << "Registering EmergencyManager!\n";
hks::createtable(L, 0, 1);
PushLuaMethod(L, lChangePlayerScore, "lChangePlayerScore", -2, "ChangePlayerScore");
hks::setfield(L, hks::LUA_GLOBAL, "EmergencyManager");
return 0;
}
void Create() {
using namespace Runtime;
ChangePlayerScore = GetGameCoreGlobalAt<Types::ChangePlayerScore>(CHANGE_PLAYER_SCORE_OFFSET);
ChangePlayerScore2 = GetGameCoreGlobalAt<Types::ChangePlayerScore2>(CHANGE_PLAYER_SCORE_2_OFFSET);
Get = GetGameCoreGlobalAt<Types::Get>(GET_OFFSET);
}
}