SetPlayerClothingPreset: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(2 intermediate revisions by one other user not shown) | |||
Line 16: | Line 16: | ||
AddCommand("preset", function (playerId, presetId) | AddCommand("preset", function (playerId, presetId) | ||
if presetId == nil then | if presetId == nil then | ||
return AddPlayerChat( | return AddPlayerChat(playerId, "Usage: /preset <preset id between 1 to 30>") | ||
end | end | ||
Line 22: | Line 22: | ||
if presetId < 0 or presetId > 30 then | if presetId < 0 or presetId > 30 then | ||
return AddPlayerChat( | return AddPlayerChat(playerId, "Error: Invalid preset Id") | ||
end | end | ||
CallRemoteEvent("SetClientClothingPreset" | CallRemoteEvent(playerId, "SetClientClothingPreset", presetId) | ||
AddPlayerChat( | AddPlayerChat(playerId, "You have set the preset "..presetId..".") | ||
end) | end) | ||
Line 36: | Line 36: | ||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[Clothing]] | |||
* [[ClothingExample]] | * [[ClothingExample]] | ||
Latest revision as of 11:09, 2 September 2020
Description
This function sets a predefined clothing preset on a player. This is for people who are not interested in setting each clothing item ClothingExample.
Syntax
SetPlayerClothingPreset(player, clothing_preset)
Parameters
- player
The player identifier. - clothing_preset
The clothing preset .
Return Value
- Returns true on success.
Example
-- Server side
AddCommand("preset", function (playerId, presetId)
if presetId == nil then
return AddPlayerChat(playerId, "Usage: /preset <preset id between 1 to 30>")
end
presetId = tonumber(presetId)
if presetId < 0 or presetId > 30 then
return AddPlayerChat(playerId, "Error: Invalid preset Id")
end
CallRemoteEvent(playerId, "SetClientClothingPreset", presetId)
AddPlayerChat(playerId, "You have set the preset "..presetId..".")
end)
-- Client side
AddRemoteEvent("SetClientClothingPreset", function (presetId)
SetPlayerClothingPreset(GetPlayerId(), presetId)
end)