Advertisement
Epilepsys

Untitled

Dec 11th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.91 KB | None | 0 0
  1.  
  2. local function OpenCoffreMenu(objs,veh)
  3. if veh:GetVehicleClass() == "smc_shifterkart" or veh:GetVehicleClass() == "smc_shifterkart" or veh:GetModel() == "models/sickness/towtruckdr.mdl" then return end
  4. local BaseBox = vgui.Create("DFrame")
  5. BaseBox:SetSize(900, 600)
  6. BaseBox:SetTitle("")
  7. BaseBox:MakePopup()
  8. BaseBox:Center()
  9. BaseBox.Paint = function(self,w,h)
  10. draw.RoundedBox(6, 0, 0, w, h, Color(0, 76, 153, 200) )
  11. draw.DrawText("Coffre de la voiture", "NPCTITLEFONT", w/2, 3, color_white, TEXT_ALIGN_CENTER)
  12. end
  13.  
  14. CoffreScrollList = vgui.Create( "DScrollPanel", BaseBox )
  15. CoffreScrollList:SetPos(10,40)
  16. CoffreScrollList:SetSize( BaseBox:GetWide()-10, BaseBox:GetTall()-40 )
  17.  
  18. local l = 0
  19. local k = 0
  20. local x = 1
  21. local z = 0
  22. for _, v in pairs(objs) do
  23.  
  24. z = z + 1
  25.  
  26. if l > 4 then
  27.  
  28. k = k + 138
  29. x = x + 5
  30. l = 0
  31.  
  32. end
  33.  
  34. l = l + 1
  35.  
  36. local model = vgui.Create( "SpawnIcon", CoffreScrollList )
  37. model:SetSize( 80, 80 )
  38. model:SetModel( v.mdl )
  39. model:SetPos( 20+(z-x)*135, k+30 )
  40. model:SetModel( v.mdl )
  41.  
  42. local fond = vgui.Create("DFrame", CoffreScrollList )
  43. fond:ShowCloseButton(false)
  44. fond:SetSize(128,128)
  45. fond:SetPos( (z-x)*135, k )
  46. fond:SetTitle("")
  47. fond:SetZPos(-1)
  48. fond:SetTooltip(v.mdl)
  49. fond.Paint = function(self, w, h )
  50.  
  51. draw.RoundedBox(0, 0, 0, w, h, Color(0, 76, 200, 255) )
  52.  
  53. draw.DrawText(v.name,"NPCTITLEFONTCD",w/2,3,Color(255,255,255),TEXT_ALIGN_CENTER)
  54.  
  55. if v.name != "Printer" && v.name != "Printer VIP" && v.name != "Nourriture" && v.name != "Bidon d'eau" && v.name != "Sac" && v.name != "Colis" then
  56.  
  57. draw.DrawText("Quantité : "..v.nb,"NPCTITLEFONTCD",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  58.  
  59. elseif v.name == "Nourriture" then
  60.  
  61. draw.DrawText(v.pv.."%","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  62.  
  63. elseif v.name == "Bidon d'eau" then
  64.  
  65. draw.DrawText(v.amount.."L","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  66.  
  67. elseif v.name == "Sac" then
  68.  
  69. draw.DrawText(v.amount.."%","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  70.  
  71. elseif v.name == "Colis" then
  72.  
  73. for _, c in pairs( ConfigCraft ) do
  74.  
  75. if v.class == c.class then
  76.  
  77. draw.DrawText(c.name,"NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  78.  
  79. end
  80.  
  81. end
  82.  
  83. elseif v.name == "Argent" then
  84.  
  85. if v.price < 1000 then
  86.  
  87. draw.DrawText("Contient : "..v.price.."€","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  88.  
  89. else
  90. draw.DrawText("Contient : "..v.price.."€","STATEFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  91.  
  92. end
  93.  
  94. else
  95.  
  96. if v.money < 1000 then
  97.  
  98. draw.DrawText("Contient : "..v.money.."€","NPCFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  99.  
  100. else
  101. draw.DrawText("Contient : "..v.money.."€","STATEFONT",w/2,h-26,Color(255,255,255),TEXT_ALIGN_CENTER)
  102.  
  103. end
  104.  
  105. end
  106.  
  107. end
  108.  
  109. local button = vgui.Create("DButton", CoffreScrollList )
  110. button:SetTooltip("Cliquer pour sortir l'objet du coffre")
  111. button:SetSize(128,128)
  112. button:SetPos(fond:GetPos())
  113. button:SetText("")
  114. button.Paint = function(self, w, h )
  115. if self:IsHovered() then
  116. surface.SetDrawColor(255,255,255)
  117. surface.DrawOutlinedRect(0,0,w,h)
  118. end
  119. end
  120. button.OnCursorEntered = function(self)
  121. surface.PlaySound("UI/buttonrollover.wav")
  122. end
  123. button.DoClick = function()
  124. if v.name == "Printer" or v.name == "Printer VIP" or v.nb == 1 then
  125. net.Start("CoffreDropObj")
  126. net.WriteString(_)
  127. net.WriteEntity(veh)
  128. net.WriteBool(false)
  129. net.SendToServer()
  130. BaseBox:Remove()
  131. else
  132. local menu = DermaMenu(button)
  133. menu:SetPos(input.GetCursorPos())
  134. menu:AddOption("Tout sortir",function()
  135. surface.PlaySound("UI/buttonclick.wav")
  136. BaseBox:Remove()
  137. net.Start("CoffreDropObj")
  138. net.WriteString(_)
  139. net.WriteEntity(veh)
  140. net.WriteBool(true)
  141. net.SendToServer()
  142. end)
  143.  
  144. menu:AddSpacer()
  145. menu:AddOption("Sortir 1 seul",function()
  146. surface.PlaySound("UI/buttonclick.wav")
  147. BaseBox:Remove()
  148. net.Start("CoffreDropObj")
  149. net.WriteString(_)
  150. net.WriteEntity(veh)
  151. net.WriteBool(false)
  152. net.SendToServer()
  153. end)
  154. menu:Open()
  155. end
  156.  
  157. end
  158.  
  159. local sbar = CoffreScrollList:GetVBar()
  160.  
  161. function sbar:Paint( w, h )
  162. end
  163. function sbar.btnUp:Paint( w, h )
  164. end
  165. function sbar.btnDown:Paint( w, h )
  166. end
  167. function sbar.btnGrip:Paint( w, h )
  168. draw.RoundedBox( 6, 4, 0, w-8, h, Color( 255, 255, 255,220 ) )
  169. if self:IsHovered() then
  170. self:SetCursor("hand")
  171. end
  172. end
  173.  
  174. end
  175.  
  176. end
  177.  
  178. net.Receive("CoffreOpenMenu", function()
  179.  
  180. OpenCoffreMenu(net.ReadTable(),net.ReadEntity())
  181.  
  182. end)
  183.  
  184. function CoffrePos(veh)
  185.  
  186. local mins, maxs = veh:OBBMins(), veh:OBBMaxs()
  187.  
  188. pos = Vector(veh:OBBCenter().x, mins.y , veh:OBBCenter().z)
  189.  
  190. pos = veh:LocalToWorld(pos)
  191.  
  192. return pos
  193.  
  194. end
  195.  
  196. local CoffreNoCars = {"rhibsgm","Yacht_2","porcycletdm"}
  197.  
  198. hook.Add("HUDPaint","DrawCoffreHUD", function()
  199.  
  200. local ent = LocalPlayer():GetEyeTrace().Entity
  201.  
  202. if IsValid(ent) && !LocalPlayer():InVehicle() then
  203.  
  204. if ent:GetClass() == "prop_vehicle_jeep" && !table.HasValue(CoffreNoCars,ent:GetVehicleClass()) then
  205.  
  206. local pos = ent:EyePos()
  207. pos.z = pos.z + 30
  208. pos = pos:ToScreen()
  209.  
  210. local dist = LocalPlayer():GetPos():Distance(ent:GetPos())
  211.  
  212. if dist < 200 then
  213.  
  214. if LocalPlayer():EyePos():Distance(CoffrePos(ent)) < 75 && ent:GetVelocity():Length() < 10 then
  215.  
  216. 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))
  217. 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))
  218.  
  219. if ent:GetNWInt("coffreweight") >= 100 then
  220.  
  221. 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))
  222.  
  223. else
  224.  
  225. 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))
  226.  
  227. end
  228.  
  229. end
  230.  
  231. end
  232.  
  233. end
  234.  
  235. end
  236.  
  237. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement