[GLua] Position des HUD

  • Initiateur de la discussion Devils_Monkey
  • Date de début
  • Initiateur de la discussion
Devils_Monkey

Devils_Monkey

Geek
Messages
315
Score réaction
12
Points
95
Salut !

J'ai un problème avec mon HUD, moi je le vois correctement mais un joueur m'as envoyer se screen:
20180709124906_1.jpg



Je voulais savoir comment faire pour que peut un port la résolution de l’écran le HUD soit en haut de l'écran.


Voici la partie de mon code qui est concerner:

Code:
------------------------------------------------------------------------------
-- --
-- Preset HUD --
-- --
------------------------------------------------------------------------------ function GetBarSize( data ) return ( 215 / 100 ) * data < 215 and ( 215 / 100 ) * data or 215 end
------------------------------------------------------------------------------
-- --
-- #HUD# --
-- --
------------------------------------------------------------------------------ hook.Add( 'HUDPaint', 'Hud_devils', function() local self = LocalPlayer() surface.DrawRect( 0, ScrH() - 900, SrcW(), 40) surface.SetDrawColor( 14, 14, 14, 255 ) surface.DrawRect( 0, ScrH() - 900, 10000, 40) surface.SetDrawColor( 0, 0, 0, 250 )
------------------------------------------------------------------------------
-- --
-- Titre HUD --
-- --
------------------------------------------------------------------------------ draw.SimpleText( self:Nick(), "HudTitle", SrcW(), ScrH(), Color( 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) draw.SimpleText( "By Devils_monkey", "HudTitle", 450, ScrH() - 880, Color(12, 12, 12, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) draw.SimpleText( "By Devils_monkey", "HudTitle", 451, ScrH() - 881, Color(12, 12, 12, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER ) draw.SimpleText( "By Devils_monkey", "HudTitle", 449, ScrH() - 879, Color(25, 25, 25, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER )
------------------------------------------------------------------------------
-- --
-- Text HUD --
-- --
------------------------------------------------------------------------------ surface.SetDrawColor( 220, 20, 60, 190 ) surface.DrawRect( 735 + 5, ScrH() - 870, GetBarSize( LocalPlayer():getDarkRPVar("Energy") ) - 5 / 2 - 20, 10 ) draw.SimpleText( LocalPlayer():getDarkRPVar("Energy") > 0 and LocalPlayer():getDarkRPVar("Energy") .. "%" or 0 .. "%", "HudFood", 840, ScrH() - 872, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) surface.SetDrawColor( 26, 26, 26 ) surface.DrawRect( 100 - 20, ScrH() - 895, 215 + 5 / 22, 24 ) surface.SetDrawColor( 220, 20, 60, 190 ) surface.DrawRect( 100 + 5, ScrH() - 895, GetBarSize( self:Health() ) - 5 / 2 - 20, 24 ) draw.SimpleText( self:Health() > 0 and self:Health() .. "%" or 0 .. "%", "HudFont", 215, ScrH() - 890, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) surface.SetDrawColor( 26, 26, 26 ) surface.DrawRect( 1307 - 20, ScrH() - 920 + 28, 215 + 5 / 22, 24 ) surface.SetDrawColor( 30, 144, 255 ) surface.DrawRect( 1307 - 30 + 5, ScrH() - 920 + 28, GetBarSize( self:Armor() > 0 and self:Armor() or 0 ) - 5 / 2 - 20, 24 ) draw.SimpleText( self:Armor() > 0 and self:Armor() .. "%" or 0 .. "%", "HudFont", 1375, ScrH() - 890, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )
------------------------------------------------------------------------------
-- --
-- Icon HUD --
-- --
------------------------------------------------------------------------------ local health_icon = Material( "icon16/heart.png" ) local shield_icon = Material( "icon16/shield.png" ) local cash_icon = Material( "icon16/money.png" ) local star_icon = Material( "icon16/star.png" ) local tick_icon = Material( "icon16/tick.png" ) local function CreateImageIcon( icon, x, y, col, val ) surface.SetDrawColor( col ) surface.SetMaterial( icon ) local w, h = 16, 16 if val then surface.SetDrawColor( Color( 255, 255, 255 ) ) end surface.DrawTexturedRect( x, y, w, h ) end CreateImageIcon( shield_icon, 1478, ScrH() - 888, Color( 30,144,255 ) ) CreateImageIcon( star_icon, 40, ScrH() - 890, Color( 40, 40, 40 ), self:isWanted() ) CreateImageIcon( tick_icon, 1527, ScrH() - 888, Color( 40, 40, 40 ), self:getDarkRPVar("HasGunlicense") ) end )
 
thepsyca

thepsyca

Psychopathe
Messages
2 164
Score réaction
648
Points
365
Au lieu de faire des ScrH() - 880 qui te prend la hauteur de ton écran et fait -880 fait directement ta pos exemple : 10 qui va te le mettre à 10 en partant du haut
 
  • Initiateur de la discussion
Devils_Monkey

Devils_Monkey

Geek
Messages
315
Score réaction
12
Points
95
Ok je test Merci ! :)
 
Discord d'entraide
Rejoignz-nous sur Discord