Besoin d'aide! urgent svp !

  • Initiateur de la discussion
JeanLaD

JeanLaD

Geek
Messages
13
Score réaction
1
Points
80
Bonjour,

Pour le serveur on a pris un HUD déjà existant et on l'as personnalisé pour rajouter une barre de faim (voir photo).
La faim fonctionne car on peut mourir de faim, cependant on ne peut pas savoir quand car la barre ne DESCENDS PAS !!!!

On ne sait pas quoi faire s'il vous plaît aidez nous !
On voudrait que la barre descende comme sur toute barre de faim normale...

Merci.
 

Pièces jointes

  • rp_bremergard_forest0005.jpg
    rp_bremergard_forest0005.jpg
    527.1 KB Vues: 33
Tueur2025

Tueur2025

Geek
Messages
38
Score réaction
5
Points
95
Bonjour est se que tu a mis sa dans t'as barre de faim :

local food =(LocalPlayer():getDarkRPVar("Energy"))
 
  • Initiateur de la discussion
JeanLaD

JeanLaD

Geek
Messages
13
Score réaction
1
Points
80
Tueur2025 à dit:
Bonjour est se que tu a mis sa dans t'as barre de faim :

local food =(LocalPlayer():getDarkRPVar("Energy"))
Oui, je l'ai mis...
Je ne sais pas ce qui va pas vraiment et sa nique tout le serveur quoi
 
Mathieu133

Mathieu133

Geek suprême
Messages
291
Score réaction
43
Points
145
Montre le code
 
  • Initiateur de la discussion
JeanLaD

JeanLaD

Geek
Messages
13
Score réaction
1
Points
80
Mathieu133 à dit:
Montre le code
Hiding default HUD
----------------------------------*/
DarkRP.disabledDefaults["modules"] = {

["hungermod"] = false,

}
local hideHUDElements = { "DarkRP_LocalPlayerHUD", "DarkRP_HUD", "CHudHealth", "CHudBattery", "CHudSuitPower","DarkRP_Hungermod" }

hook.Add("HUDShouldDraw", "MHUD_Hide", function(name)
if table.HasValue(hideHUDElements, name) then return false end
end)



local function StartStencil()
render.ClearStencil()
render.SetStencilEnable( true )
render.SetStencilWriteMask( 1 )
render.SetStencilTestMask( 1 )
render.SetStencilFailOperation( STENCILOPERATION_KEEP )
render.SetStencilZFailOperation( STENCILOPERATION_KEEP )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_ALWAYS )
render.SetStencilReferenceValue( 1 )
render.SetColorModulation( 1, 1, 1 )
end

local function StencilReplace()
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
render.SetStencilReferenceValue(1)
end

local function StencilEnd()
render.SetStencilEnable( false )
end



local Base = Material("materials/mhud/Statusbarv1.png")
local HPBg = Material("materials/mhud/healthbarbackv1.png")
local HPFull = Material("materials/mhud/healthbarfullv1.png")

local FoodBg = Material("materials/mhud/foodbarbackv1.png")
local FoodFull = Material("materials/mhud/foodbarfullv1.png")

local ArmorBar = Material("materials/mhud/armorbarv2.png")
local ArmorBarBg = Material("materials/mhud/healthbaremptryv1.png")
local ArmorBarFull = Material("materials/mhud/Armorbarfullv1.png")

local CashBar = Material("materials/mhud/cashbarv1.png")


local HP = 100
local Armor = 100
local Food = 100

surface.CreateFont("NameFont", {
font = "hudfont",
size = 14,
weight = 5000,
blursize = 0,
scanlines = 0,
antialias = true,
})

surface.CreateFont("MoneyFont", {
font = "hudfont",
size = 17,
weight = 5000,
blursize = 0,
scanlines = 0,
antialias = true,
})

surface.CreateFont("JobFont", {
font = "hudfont",
size = 21,
weight = 5000,
blursize = 0,
scanlines = 0,
antialias = true,
})

function DrawHUD()
local x, y = 35, 15

surface.SetDrawColor(255,255,255)

surface.SetMaterial(HPBg)
surface.DrawTexturedRect(x + 100, y + 32, 328, 28)

StartStencil()
surface.SetDrawColor(255,255,255,1)
surface.DrawRect(x + 100, y + 32, 328 * math.Clamp(HP,0,100)/100, 28)
StencilReplace()
surface.SetDrawColor(255,255,255)
surface.SetMaterial(HPFull)
surface.DrawTexturedRect(x + 97, y + 32, 328, 28)
StencilEnd()
surface.SetDrawColor(255,255,255)

surface.SetMaterial(FoodBg)
surface.DrawTexturedRect(x + 106, y + 59, 300, 18)
StartStencil()
surface.SetDrawColor(255,255,255,1)
surface.DrawRect(x + 106, y + 59, 300 * math.Clamp(Food,0,100)/100, 18)
StencilReplace()
surface.SetDrawColor(255,255,255)
surface.SetMaterial(FoodFull)
surface.DrawTexturedRect(x + 103, y + 59, 300, 18)
StencilEnd()
HP = Lerp(0.1, HP, LocalPlayer():Health())
Food = Lerp(0.1, Food, LocalPlayer():getDarkRPVar("Energy"))

surface.SetMaterial(Base)
surface.DrawTexturedRect(x, y, 439, 98)

draw.DrawText((LocalPlayer():getDarkRPVar("job") or team.GetName(LocalPlayer():Team())), "JobFont", x + 270 , y + 77, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER)

draw.DrawText(LocalPlayer():Nick(), "NameFont", x + 290 , y + 19, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER)


local x, y = 5, 55

surface.SetMaterial(ArmorBarBg)
surface.DrawTexturedRect(x + 4, y + 3.5, 63, 78)

StartStencil()
surface.SetDrawColor(255,255,255,1)
local matr = Matrix()
matr:Translate(Vector(125,80,0))
matr:Rotate(Angle(0,20 + (Armor/100) * 70,0))
matr:Translate(-Vector(125,80,0))
cam.PushModelMatrix(matr)
local radius = 120
local count = 50
local posx, posy = 125, 80
local vertices = { }
for i=0, count-24 do
vertices[i+1] = {x=math.sin(-math.rad(i/count*360)) * radius + posx, y=math.cos(-math.rad(i/count*360)) * radius + posy}
end
surface.DrawPoly(vertices)
cam.PopModelMatrix()

render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
render.SetStencilReferenceValue(0)

surface.SetDrawColor(255,255,255,255)

surface.SetMaterial(ArmorBarFull)
surface.DrawTexturedRect(x + 5, y + 5, 66, 80)
StencilEnd()

Armor = Lerp(0.1, Armor, LocalPlayer():Armor())

surface.SetDrawColor(255,255,255,255)

surface.SetMaterial(ArmorBar)
surface.DrawTexturedRect(x, y, 129, 130)


local x, y = 135, 120

surface.SetMaterial(CashBar)
surface.DrawTexturedRect(x, y, 261, 67)

draw.DrawText(DarkRP.formatMoney(LocalPlayer():getDarkRPVar("money")), "MoneyFont", x + 138 , y + 26, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER)

draw.DrawText(DarkRP.formatMoney(LocalPlayer():getDarkRPVar("salary")), "NameFont", x + 238 , y + 27, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER)

end
hook.Add("HUDPaint", "MHUD", DrawHUD)





Voilà ! x)
La faim est bien active sur le serveur mais la barre ne descends pas en fonction de celle-ci... Elle reste toujours pleine
 
  • Initiateur de la discussion
JeanLaD

JeanLaD

Geek
Messages
13
Score réaction
1
Points
80
Mathieu133 à dit:
Montre le code
Malgré sa la valeure reste nulle

DarkRP.disabledDefaults["modules"] = { ["hungermod"] = false, }
 
Discord d'entraide
Rejoignz-nous sur Discord