- Documentation
- Shared functions
- getValidPedModels
Function
getValidPedModels
Returns a list of every valid ped model number, i.e. the skins you can pass to createPed, setElementModel or spawnPlayer. Numbers with no ped behind them in the game are left out. By default it also includes new ped models added by script with engineRequestModel. Useful for picking a random skin or building a character selection menu.
Syntax
table getValidPedModels([bool includeCustom = true])Arguments
includeCustombool, optional = truetrueincludes new ped models fromengineRequestModel;falsereturns only the game's own models.Not in MTA:SA
Differences from MTA:SA
- Arguments in a different colour differ from MTA:SA.
In MTA:SA
getValidPedModels()Returns
A table of numbers (model IDs) sorted ascending.
Example
local models = getValidPedModels(false)
addCommandHandler("losujskin", function(player)
setElementModel(player, models[math.random(#models)])
end)
See also
isValidPedModelChecks whether a model number is a real ped model that can be used increatePed,setElementModelorspawnPlayer. It accepts the game's models (0-311 except empty numbers) and new peds added withengineRequestModel. Call it before applying a skin a player typed into a command.createPedCreates a new NPC ped on the server (a pedestrian driven by the game, not by a player) and shows it right away to every player nearby. The ped gets 100 health, a random appearance variant (clothes and skin tone, seesetPedVariant) and belongs to the resource that created it, so it disappears together with that resource onstop. Optionally it can be made aggressive straight away or told to attack a chosen target.setElementModelChanges the element's model. For players and peds you can also pass the clothing and skin variant (0-3); without them the server picks one so everyone sees the same.