Skip to content

Commit 889567a

Browse files
Add "includeCustom" argument for getValidPedModels clientside (#3796)
1 parent 7e6b4d0 commit 889567a

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionDefs.Util.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,40 @@
1212

1313
int CLuaFunctionDefs::GetValidPedModels(lua_State* luaVM)
1414
{
15-
int iIndex = 0;
15+
bool includeCustom;
16+
CScriptArgReader argStream(luaVM);
17+
argStream.ReadBool(includeCustom, true);
18+
19+
auto* modelManager = g_pClientGame->GetManager()->GetModelManager();
20+
21+
std::size_t index = 0;
1622
lua_newtable(luaVM);
1723

18-
// Gather GTASA default skins
19-
for (int i = 0; i <= 312; i++)
24+
// Gather default and possibly custom GTASA ped model IDs
25+
for (std::size_t i = 0; i <= 312; i++)
2026
{
2127
if (CClientPlayerManager::IsValidModel(i))
2228
{
23-
lua_pushnumber(luaVM, ++iIndex);
29+
// Skip custom skins if not requested
30+
if (!includeCustom && modelManager->FindModelByID(i))
31+
continue;
32+
33+
lua_pushnumber(luaVM, ++index);
2434
lua_pushnumber(luaVM, i);
2535
lua_settable(luaVM, -3);
2636
}
2737
}
2838

29-
// Gather our custom skin model IDs allocated with engineRequestModel
30-
// (there might be some < 313 as well, and since we don't want duplicates, we start at 313, others are already included by the loop above)
31-
for (const auto& model : m_pManager->GetModelManager()->GetModelsByType(eClientModelType::PED, 313))
39+
if (includeCustom)
3240
{
33-
lua_pushnumber(luaVM, ++iIndex);
34-
lua_pushnumber(luaVM, model->GetModelID());
35-
lua_settable(luaVM, -3);
41+
// Gather the rest of custom skin model IDs allocated with engineRequestModel
42+
// (there are usually some < 313 as well, and since we don't want duplicates, we start at 313, others are already included by the loop above)
43+
for (const auto& model : m_pManager->GetModelManager()->GetModelsByType(eClientModelType::PED, 313))
44+
{
45+
lua_pushnumber(luaVM, ++index);
46+
lua_pushnumber(luaVM, model->GetModelID());
47+
lua_settable(luaVM, -3);
48+
}
3649
}
3750

3851
return 1;

0 commit comments

Comments
 (0)