GetValidPedModels: Difference between revisions
Jump to navigation
Jump to search
m (Wrong. This is only a server-side function, not both.) |
Fernando187 (talk | contribs) mNo edit summary |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Server function}} | {{Server client function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function returns all valid ped models. | This function returns all valid ped models. The syntax is different for server and client sides. | ||
==Syntax== | ==Syntax== | ||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
table getValidPedModels ( [ bool includeCustom = true ] ) | |||
</syntaxhighlight> | |||
===Optional Arguments=== | |||
{{OptionalArg}} | |||
{{New feature/item|3.0161|1.6.0|22780| | |||
*'''includeCustom:''' Specifies if the table returned should contain custom model IDs allocated with [[engineRequestModel]]. | |||
}} | |||
===Returns=== | |||
Returns a [[table]] with all valid ped models that exist on the client, containing the custom model IDs unless '''includeCustom''' is false. | |||
</section> | |||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
table getValidPedModels ( ) | table getValidPedModels ( ) | ||
Line 9: | Line 26: | ||
===Returns=== | ===Returns=== | ||
Returns a [[table]] with all valid ped models. | Returns a [[table]] with all valid ped models that exist on the server. | ||
</section> | |||
== | ==Examples== | ||
This example will | This example will check if the specified skin ID is a valid skin via a command. | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function isValidSkin( thePlayer, command, specifiedSkin ) | function isValidSkin( thePlayer, command, specifiedSkin ) | ||
specifiedSkin = tonumber ( specifiedSkin ) | |||
if ( specifiedSkin ) then -- If skin specified | if ( specifiedSkin ) then -- If skin specified | ||
local allSkins = getValidPedModels ( ) -- Get valid skin IDs | local allSkins = getValidPedModels ( ) -- Get valid skin IDs | ||
local result = false -- Define result, it is currently false | local result = false -- Define result, it is currently false | ||
for | for _, skin in ipairs( allSkins ) do -- Check all skins | ||
if skin == | if skin == specifiedSkin then -- If skin equals specified one, it is valid | ||
result = | result = true -- So set it as result | ||
break --stop looping through a table after we found the skin | break -- stop looping through a table after we found the skin | ||
end | end | ||
end | end | ||
if ( result ) then -- If we got results | if ( result ) then -- If we got results | ||
outputChatBox( | outputChatBox( specifiedSkin .. " is a valid skin ID.", thePlayer, 0, 255, 0 ) -- It is valid, output it | ||
else -- If we didn't get results | else -- If we didn't get results | ||
outputChatBox( specifiedSkin .. " is not a valid skin ID.", thePlayer, 0, 255, 0 ) -- No result, it is not valid | outputChatBox( specifiedSkin .. " is not a valid skin ID.", thePlayer, 0, 255, 0 ) -- No result, it is not valid | ||
end | end | ||
else | else | ||
outputChatBox( "Please specify a | outputChatBox( "Please specify a valid number to check!", thePlayer, 255, 0, 0 ) | ||
end | end | ||
end | end | ||
addCommandHandler("checkskin",isValidSkin) -- bind 'checkskin' command to 'isValidSkin' function | addCommandHandler("checkskin",isValidSkin) -- bind 'checkskin' command to 'isValidSkin' function | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{Ped functions}} | {{Ped functions}} | ||
[[ru:getValidPedModels]] | |||
[[pl:GetValidPedModels]] |
Latest revision as of 08:17, 15 October 2024
This function returns all valid ped models. The syntax is different for server and client sides.
Syntax
Click to collapse [-]
Clienttable getValidPedModels ( [ bool includeCustom = true ] )
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
Returns
Returns a table with all valid ped models that exist on the client, containing the custom model IDs unless includeCustom is false.
Click to collapse [-]
Servertable getValidPedModels ( )
Returns
Returns a table with all valid ped models that exist on the server.
Examples
This example will check if the specified skin ID is a valid skin via a command.
function isValidSkin( thePlayer, command, specifiedSkin ) specifiedSkin = tonumber ( specifiedSkin ) if ( specifiedSkin ) then -- If skin specified local allSkins = getValidPedModels ( ) -- Get valid skin IDs local result = false -- Define result, it is currently false for _, skin in ipairs( allSkins ) do -- Check all skins if skin == specifiedSkin then -- If skin equals specified one, it is valid result = true -- So set it as result break -- stop looping through a table after we found the skin end end if ( result ) then -- If we got results outputChatBox( specifiedSkin .. " is a valid skin ID.", thePlayer, 0, 255, 0 ) -- It is valid, output it else -- If we didn't get results outputChatBox( specifiedSkin .. " is not a valid skin ID.", thePlayer, 0, 255, 0 ) -- No result, it is not valid end else outputChatBox( "Please specify a valid number to check!", thePlayer, 255, 0, 0 ) end end addCommandHandler("checkskin",isValidSkin) -- bind 'checkskin' command to 'isValidSkin' function
See Also
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle