-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
77 lines (64 loc) · 1.65 KB
/
main.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/
// Required for most of open.mp.
#include <sdk.hpp>
// This should use an abstract interface if it is to be passed to other components. Like the files
// in `<Server/Components/>` you would share only this base class and keep the implementation
// private.
class EmptyTemplate final : public IComponent
{
private:
// Hold a reference to the main server core.
ICore* core_ = nullptr;
public:
// Visit https://open.mp/uid to generate a new unique ID.
PROVIDE_UID(/* UID GOES HERE */);
// When this component is destroyed we need to tell any linked components this it is gone.
~EmptyTemplate()
{
}
// Implement the main component API.
StringView componentName() const override
{
return "Empty Template";
}
SemanticVersion componentVersion() const override
{
return SemanticVersion(0, 0, 1, 0);
}
void onLoad(ICore* c) override
{
// Cache core, player pool here.
core_ = c;
core_->printLn("Empty component template loaded.");
}
void onInit(IComponentList* components) override
{
}
void onReady() override
{
// Fire events here at earliest.
}
void onFree(IComponent* component) override
{
}
void free() override
{
// Deletes the component.
delete this;
}
void reset() override
{
// Resets data when the mode changes.
}
};
// Automatically called when the compiled binary is loaded.
COMPONENT_ENTRY_POINT()
{
return new EmptyTemplate();
}