SetPlayerClothingPreset: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 17: Line 17:
     if presetId == nil then
     if presetId == nil then
         return AddPlayerChat(playerid, "Usage: /preset <preset id between 1 to 30>")
         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
     end


     CallRemoteEvent("SetClientClothingPreset", playerId, presetId)
     CallRemoteEvent("SetClientClothingPreset", playerId, presetId)
    AddPlayerChat(playerid, "You have set the preset "..presetId..".")
end)
end)


Line 30: Line 37:
{{RelatedFunctions}}
{{RelatedFunctions}}
* [[ClothingExample]]
* [[ClothingExample]]
{{ClientPlayerFunctions}}

Revision as of 15:06, 18 December 2019

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("SetClientClothingPreset", playerId, presetId)
    AddPlayerChat(playerid, "You have set the preset "..presetId..".")
end)

-- Client side
AddRemoteEvent("SetClientClothingPreset", function (presetId)
    SetPlayerClothingPreset(GetPlayerId(), presetId)
end)

See also

Template:ClientPlayerFunctions