SetPlayerClothingPreset: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|This function sets a predefined clothing preset on a player. This is for people who are not interested in setting each clothing..."
 
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 9: Line 9:
{{FuncParam|clothing_preset|The clothing preset .}}
{{FuncParam|clothing_preset|The clothing preset .}}


{{FuncReturnValue|The client's location.}}
{{FuncReturnValue|Returns '''true''' on success.}}


== Example ==
== Example ==
<syntaxhighlight lang="Lua">
<syntaxhighlight lang="Lua">
AddEvent("OnRenderHUD", function()
-- Server side
local x, y, z = GetPlayerLocation()
AddCommand("preset", function (playerId, presetId)
AddPlayerChat("Player location: "..x..", "..y..", "..z)
    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)
end)
</syntaxhighlight>
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
* [[SetPlayerLocation]]
* [[Clothing]]
* [[ClothingExample]]

Latest revision as of 11:09, 2 September 2020

SetPlayerClothingPreset

Type: Function
Context: Client
Introduced: v1.0

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)

See also