SetPlayerHudComponentProperty: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Client function}} {{New feature/item|3.0161|1.6.0|22868|This function allows for modifying HUD properties, such as text or bar color, position, size, and more.}} {{Note|Due to a rendering bug in GTA, setting transparency for text with outline or shadow causes a visual glitch, resulting in blurred/smudged text. Transparency only works correctly on text without outline and shadow.}} thumb|right|Example of a modified HUD. ==Syntax=...") |
m (Tip) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
{{Note|Due to a rendering bug in GTA, setting transparency for text with outline or shadow causes a visual glitch, resulting in blurred/smudged text. Transparency only works correctly on text without outline and shadow.}} | {{Note|Due to a rendering bug in GTA, setting transparency for text with outline or shadow causes a visual glitch, resulting in blurred/smudged text. Transparency only works correctly on text without outline and shadow.}} | ||
{{Tip|If the characters are uneven after changing the font, you should set the '''proportional''' property to '''true'''}} | |||
{{Tip|The health bar is positioned relative to its width, so after changing its width, its position on the X-axis will also change. If you want to maintain the bar's position, you also need to calculate its position based on its width. Additionally, the width is calculated depending on the MAX_HEALTH stat.}} | |||
[[File:HUD properties.png|thumb|right|Example of a modified HUD.]] | [[File:HUD properties.png|thumb|right|Example of a modified HUD.]] | ||
Line 14: | Line 18: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''component:''' The component you wish to | *'''component:''' The component you wish to modify. See [[HUD Components]]. | ||
*'''property:''' The name of the property you want to modify. See [[HUD Components#Properties|HUD Properties]]. | *'''property:''' The name of the property you want to modify. See [[HUD Components#Properties|HUD Properties]]. | ||
*'''value:''' The value you want to set. | *'''value:''' The value you want to set. |
Latest revision as of 14:20, 6 January 2025
Tip: If the characters are uneven after changing the font, you should set the proportional property to true |
Tip: The health bar is positioned relative to its width, so after changing its width, its position on the X-axis will also change. If you want to maintain the bar's position, you also need to calculate its position based on its width. Additionally, the width is calculated depending on the MAX_HEALTH stat. |
Syntax
bool setPlayerHudComponentProperty (string component, string property, mixed value)
OOP Syntax Help! I don't understand this!
- Method: player:setHudComponentProperty(...)
- Counterpart: getPlayerHudComponentProperty
Required Arguments
- component: The component you wish to modify. See HUD Components.
- property: The name of the property you want to modify. See HUD Properties.
- value: The value you want to set.
Returns
Returns true if the property was successfully modified, false otherwise.
Example
This example makes the HUD look like it does in the picture on the side.
addEventHandler('onClientResourceStart', resourceRoot, function() setPlayerHudComponentProperty('clock', 'fillColor', tocolor(50, 168, 82, 255)) setPlayerHudComponentProperty('clock', 'dropColor', tocolor(94, 14, 7, 255)) setPlayerHudComponentProperty('clock', 'fontOutline', 1) setPlayerHudComponentProperty('clock', 'fontStyle', 'subtitles') setPlayerHudComponentProperty('clock', 'proportional', true) setPlayerHudComponentProperty('money', 'fillColor', tocolor(11, 102, 158, 255)) setPlayerHudComponentProperty('money', 'fillColorSecondary', tocolor(176, 23, 130, 255)) setPlayerHudComponentProperty('money', 'fontOutline', 1) setPlayerHudComponentProperty('money', 'fontStyle', 'subtitles') setPlayerHudComponentProperty('health', 'fillColor', tocolor(50, 168, 82, 255)) setPlayerHudComponentProperty('ammo', 'fillColor', tocolor(245, 66, 126, 255)) setPlayerHudComponentProperty('weapon', 'fillColor', tocolor(235, 76, 52, 255)) setPlayerHudComponentProperty('wanted', 'fillColorSecondary', tocolor(140, 138, 137, 255)) setPlayerHudComponentProperty('wanted', 'fillColor', tocolor(66, 33, 252, 255)) end)
See Also
- getLocalPlayer
- getPlayerMapBoundingBox
- getPlayerMapOpacity
- isPlayerMapVisible
- isPlayerHudComponentVisible
- resetBlurLevel
- Shared
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState