-
-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathNatives.cpp
More file actions
136 lines (106 loc) · 3.16 KB
/
Natives.cpp
File metadata and controls
136 lines (106 loc) · 3.16 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* 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.
*/
#include "../Types.hpp"
#include "sdk.hpp"
SCRIPT_API(AddCharModel, bool(int baseid, int newid, std::string const& dff, std::string const& textureLibrary))
{
auto models = PawnManager::Get()->models;
if (!models)
return false;
return models->addCustomModel(ModelType::Skin, newid, baseid, dff, textureLibrary);
}
SCRIPT_API(AddSimpleModel, bool(int virtualWorld, int baseid, int newid, std::string const& dff, std::string const& textureLibrary))
{
auto models = PawnManager::Get()->models;
if (!models)
return false;
return models->addCustomModel(ModelType::Object, newid, baseid, dff, textureLibrary, virtualWorld);
}
SCRIPT_API(AddSimpleModelTimed, bool(int virtualWorld, int baseid, int newid, std::string const& dff, std::string const& textureLibrary, int timeOn, int timeOff))
{
auto models = PawnManager::Get()->models;
if (!models)
return false;
return models->addCustomModel(ModelType::Object, newid, baseid, dff, textureLibrary, virtualWorld, timeOn, timeOff);
}
SCRIPT_API(GetPlayerCustomSkin, int(IPlayer& player))
{
IPlayerCustomModelsData* data = queryExtension<IPlayerCustomModelsData>(player);
if (!data)
{
return 0;
}
return data->getCustomSkin();
}
SCRIPT_API(RedirectDownload, bool(IPlayer& player, std::string const& url))
{
IPlayerCustomModelsData* data = queryExtension<IPlayerCustomModelsData>(player);
if (!data)
{
return false;
}
if (!data->sendDownloadUrl(url))
{
PawnManager::Get()->core->logLn(LogLevel::Warning, "This native can be used only within OnPlayerRequestDownload callback.");
return false;
}
return true;
}
SCRIPT_API(FindModelFileNameFromCRC, bool(int crc, OutputOnlyString& output))
{
auto models = PawnManager::Get()->models;
if (!models)
{
return false;
}
output = models->getModelNameFromChecksum(crc);
return std::get<StringView>(output).length();
}
SCRIPT_API(FindTextureFileNameFromCRC, bool(int crc, OutputOnlyString& output))
{
return openmp_scripting::FindModelFileNameFromCRC(crc, output);
}
SCRIPT_API(IsValidCustomModel, bool(int modelId))
{
auto models = PawnManager::Get()->models;
if (!models)
{
return false;
}
return models->isValidCustomModel(modelId);
}
SCRIPT_API(GetCustomModelPath, bool(int modelId, OutputOnlyString& dffPath, OutputOnlyString& txdPath))
{
auto models = PawnManager::Get()->models;
if (!models)
{
return false;
}
StringView dffPathSV {};
StringView txdPathSV {};
auto status = models->getCustomModelPath(modelId, dffPathSV, txdPathSV);
dffPath = dffPathSV;
txdPath = txdPathSV;
return status;
}
SCRIPT_API(SetModelDownloadAtConnect, bool(bool value))
{
auto models = PawnManager::Get()->models;
if (!models)
return false;
return models->setModelDownloadAtConnect(value);
}
SCRIPT_API(StartDownloadForPlayer, bool(IPlayer& player))
{
auto models = PawnManager::Get()->models;
if (!models)
{
return false;
}
return models->startDownloadForPlayer(player);
}