Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function OpenCoffreMenu(objs,veh)
- if veh:GetVehicleClass() == "smc_shifterkart" or veh:GetVehicleClass() == "smc_shifterkart" or veh:GetModel() == "models/sickness/towtruckdr.mdl" then return end
- local BaseBox = vgui.Create("DFrame")
- BaseBox:SetSize(900, 600)
- BaseBox:SetTitle("")
- BaseBox:MakePopup()
- BaseBox:Center()
- BaseBox.Paint = function(self,w,h)
- draw.RoundedBox(6, 0, 0, w, h, Color(0, 76, 153, 200) )
- draw.DrawText("Coffre de la voiture", "NPCTITLEFONT", w/2, 3, color_white, TEXT_ALIGN_CENTER)
- end
- CoffreScrollList = vgui.Create( "DScrollPanel", BaseBox )
- CoffreScrollList:SetPos(10,40)
- CoffreScrollList:SetSize( BaseBox:GetWide()-10, BaseBox:GetTall()-40 )
- local l = 0
- local k = 0
- local x = 1
- local z = 0
- for _, v in pairs(objs) do
- z = z + 1
- if l > 4 then
- k = k + 138
- x = x + 5
- l = 0
- end
- l = l + 1
- local model = vgui.Create( "SpawnIcon", CoffreScrollList )
- model:SetSize( 80, 80 )
- model:SetModel( v.mdl )
- model:SetPos( 20+(z-x)*135, k+30 )
- model:SetModel( v.mdl )
- local fond = vgui.Create("DFrame", CoffreScrollList )
- fond:ShowCloseButton(false)
- fond:SetSize(128,128)
- fond:SetPos( (z-x)*135, k )
- fond:SetTitle("")
- fond:SetZPos(-1)
- fond:SetTooltip(v.mdl)
- fond.Paint = function(self, w, h )
- draw.RoundedBox(0, 0, 0, w, h, Color(0, 76, 200, 255) )
- draw.DrawText(v.name,"NPCTITLEFONTCD",w/2,3,Color(255,255,255),TEXT_ALIGN_CENTER)
- if v.name != "Printer" && v.name != "Printer VIP" && v.name != "Nourriture" && v.name != "Bidon d'eau" && v.name != "Sac" && v.name != "Colis" then
- draw.DrawText("Quantité : "..v.nb,"NPCTITLEFONTCD",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- elseif v.name == "Nourriture" then
- draw.DrawText(v.pv.."%","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- elseif v.name == "Bidon d'eau" then
- draw.DrawText(v.amount.."L","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- elseif v.name == "Sac" then
- draw.DrawText(v.amount.."%","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- elseif v.name == "Colis" then
- for _, c in pairs( ConfigCraft ) do
- if v.class == c.class then
- draw.DrawText(c.name,"NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- end
- end
- elseif v.name == "Argent" then
- if v.price < 1000 then
- draw.DrawText("Contient : "..v.price.."€","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- else
- draw.DrawText("Contient : "..v.price.."€","STATEFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- end
- else
- if v.money < 1000 then
- draw.DrawText("Contient : "..v.money.."€","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- else
- draw.DrawText("Contient : "..v.money.."€","STATEFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
- end
- end
- end
- local button = vgui.Create("DButton", CoffreScrollList )
- button:SetTooltip("Cliquer pour sortir l'objet du coffre")
- button:SetSize(128,128)
- button:SetPos(fond:GetPos())
- button:SetText("")
- button.Paint = function(self, w, h )
- if self:IsHovered() then
- surface.SetDrawColor(255,255,255)
- surface.DrawOutlinedRect(0,0,w,h)
- end
- end
- button.OnCursorEntered = function(self)
- surface.PlaySound("UI/buttonrollover.wav")
- end
- button.DoClick = function()
- if v.name == "Printer" or v.name == "Printer VIP" or v.nb == 1 then
- net.Start("CoffreDropObj")
- net.WriteString(_)
- net.WriteEntity(veh)
- net.WriteBool(false)
- net.SendToServer()
- BaseBox:Remove()
- else
- local menu = DermaMenu(button)
- menu:SetPos(input.GetCursorPos())
- menu:AddOption("Tout sortir",function()
- surface.PlaySound("UI/buttonclick.wav")
- BaseBox:Remove()
- net.Start("CoffreDropObj")
- net.WriteString(_)
- net.WriteEntity(veh)
- net.WriteBool(true)
- net.SendToServer()
- end)
- menu:AddSpacer()
- menu:AddOption("Sortir 1 seul",function()
- surface.PlaySound("UI/buttonclick.wav")
- BaseBox:Remove()
- net.Start("CoffreDropObj")
- net.WriteString(_)
- net.WriteEntity(veh)
- net.WriteBool(false)
- net.SendToServer()
- end)
- menu:Open()
- end
- end
- local sbar = CoffreScrollList:GetVBar()
- function sbar:Paint( w, h )
- end
- function sbar.btnUp:Paint( w, h )
- end
- function sbar.btnDown:Paint( w, h )
- end
- function sbar.btnGrip:Paint( w, h )
- draw.RoundedBox( 6, 4, 0, w-8, h, Color( 255, 255, 255,220 ) )
- if self:IsHovered() then
- self:SetCursor("hand")
- end
- end
- end
- end
- net.Receive("CoffreOpenMenu", function()
- OpenCoffreMenu(net.ReadTable(),net.ReadEntity())
- end)
- function CoffrePos(veh)
- local mins, maxs = veh:OBBMins(), veh:OBBMaxs()
- pos = Vector(veh:OBBCenter().x, mins.y , veh:OBBCenter().z)
- pos = veh:LocalToWorld(pos)
- return pos
- end
- local CoffreNoCars = {"rhibsgm","Yacht_2","porcycletdm"}
- hook.Add("HUDPaint","DrawCoffreHUD", function()
- local ent = LocalPlayer():GetEyeTrace().Entity
- if IsValid(ent) && !LocalPlayer():InVehicle() then
- if ent:GetClass() == "prop_vehicle_jeep" && !table.HasValue(CoffreNoCars,ent:GetVehicleClass()) then
- local pos = ent:EyePos()
- pos.z = pos.z + 30
- pos = pos:ToScreen()
- local dist = LocalPlayer():GetPos():Distance(ent:GetPos())
- if dist < 200 then
- if LocalPlayer():EyePos():Distance(CoffrePos(ent)) < 75 && ent:GetVelocity():Length() < 10 then
- draw.SimpleTextOutlined("Ouvrir le coffre", "trust_npc_font", pos.x, pos.y+280-dist*1, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(1,1,1))
- draw.SimpleTextOutlined("Appuyez sur E", "trust_npc_font2", pos.x, pos.y+305-dist*1, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(1,1,1))
- if ent:GetNWInt("coffreweight") >= 100 then
- draw.SimpleTextOutlined("Coffre plein", "trust_npc_font2", pos.x, pos.y+340-dist*1, Color(255,0,0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(1,1,1))
- else
- draw.SimpleTextOutlined(ent:GetNWInt("coffreweight").."/100 kg", "trust_npc_font2", pos.x, pos.y+340-dist*1, Color(0,255,0), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(1,1,1))
- end
- end
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement