|
12 | 12 |
|
13 | 13 | int CLuaFunctionDefs::GetValidPedModels(lua_State* luaVM) |
14 | 14 | { |
15 | | - int iIndex = 0; |
| 15 | + bool includeCustom = false; |
| 16 | + CScriptArgReader argStream(luaVM); |
| 17 | + argStream.ReadBool(includeCustom); |
| 18 | + |
| 19 | + auto modelManager = g_pClientGame->GetManager()->GetModelManager(); |
| 20 | + |
| 21 | + std::size_t index = 0; |
16 | 22 | lua_newtable(luaVM); |
17 | 23 |
|
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++) |
20 | 26 | { |
21 | 27 | if (CClientPlayerManager::IsValidModel(i)) |
22 | 28 | { |
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); |
24 | 34 | lua_pushnumber(luaVM, i); |
25 | 35 | lua_settable(luaVM, -3); |
26 | 36 | } |
27 | 37 | } |
28 | 38 |
|
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) |
32 | 40 | { |
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 | + } |
36 | 49 | } |
37 | 50 |
|
38 | 51 | return 1; |
|
0 commit comments