Advertisement
Mathilde411

instructor_menu

Jul 21st, 2017
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.52 KB | None | 0 0
  1. local function DrawGUI()
  2.     local frame = vgui.Create("DFrame")
  3.     frame:Center()
  4.     frame:SetSize(140,80)
  5.     frame:SetTitle("")
  6.     frame:MakePopup()
  7.     frame:ShowCloseButton(true)
  8.     frame:SetDraggable( true )
  9.  
  10.     local player_select = vgui.Create("DComboBox", frame)
  11.     player_select:SetPos(10, 30)
  12.     player_select:SetSize(120, 20)
  13.     player_select:SetText("Selectionnez un Joueur")
  14.     for k, v in pairs(player.GetAll()) do
  15.         player_select:AddChoice(tostring(v:Name()))
  16.     end
  17.  
  18.     local submit_but = vgui.Create("DButton", frame)
  19.     submit_but:SetSize(120,20)
  20.     submit_but:SetPos(10,50)
  21.     submit_but:SetText("Info")
  22.     submit_but.DoClick = function()
  23.         if(not player_select:GetValue() or player_select:GetValue() == "Selectionnez un Joueur") then return end
  24.         frame:Close()
  25.         net.Start("instructor_menu")
  26.         net.WriteString(player_select:GetValue())
  27.         net.SendToServer()
  28.     end
  29. end
  30. net.Receive("instructor_menu", DrawGUI)
  31.  
  32. local function DrawInfoGUI()
  33.     local car_checkbox = nil
  34.     local bus_checkbox = nil
  35.     local truck_checkbox = nil
  36.     local car_points = nil
  37.     local bus_points = nil
  38.     local truck_points = nil
  39.     local car_instructor_checkbox = nil
  40.     local bus_instructor_checkbox = nil
  41.     local truck_instructor_checkbox = nil
  42.    
  43.     local infos = net.ReadTable()
  44.     local tabs = 0
  45.     if infos["car"] then tabs = tabs + 1 end
  46.     if infos["bus"] then tabs = tabs + 1 end
  47.     if infos["truck"] then tabs = tabs + 1 end
  48.     if infos["carInstructor"] then tabs = tabs + 2 end
  49.     if tabs == 0 then return end
  50.  
  51.     local frame = vgui.Create("DFrame")
  52.     frame:Center()
  53.     frame:SetSize(135, 200)
  54.     frame:SetTitle(infos["name"])
  55.     frame:MakePopup()
  56.     frame:ShowCloseButton(true)
  57.     frame:SetDraggable( true )
  58.    
  59.     local main_label = vgui.Create("DLabel", frame)
  60.     main_label:SetPos(5, 20)
  61.     main_label:SetText("Permis:")
  62.     local initial = 40
  63.     if infos["car"] then
  64.         car_checkbox = vgui.Create("DCheckBox", frame)
  65.         car_checkbox:SetPos(5, initial)
  66.         car_checkbox:SetValue(infos["car"])
  67.         local car_label = vgui.Create("DLabel", frame)
  68.         car_label:SetPos(22, initial - 3)
  69.         car_label:SetText("Voiture")
  70.         car_points = vgui.Create("DNumberWang", frame)
  71.         car_points:SetPos(70, initial)
  72.         car_points:SetValue(infos["carPoints"])
  73.         car_points:SetSize(25, 15)
  74.         car_points:SetMinMax(0, 12)
  75.         car_points:SetDecimals(0)
  76.         local car_label_points = vgui.Create("DLabel", frame)
  77.         car_label_points:SetPos(97, initial - 3)
  78.         car_label_points:SetText("Points")
  79.         initial = initial + 20
  80.         car_checkbox.OnChange = function()
  81.             if (car_checkbox:GetChecked()) then
  82.                 car_points:SetValue(12)
  83.             else
  84.                 car_points:SetValue(0)
  85.             end
  86.         end
  87.     end
  88.    
  89.     if infos["bus"] then
  90.         bus_checkbox = vgui.Create("DCheckBox", frame)
  91.         bus_checkbox:SetPos(5, initial)
  92.         bus_checkbox:SetValue(infos["bus"])
  93.         local bus_label = vgui.Create("DLabel", frame)
  94.         bus_label:SetPos(22, initial - 3)
  95.         bus_label:SetText("Bus")
  96.         bus_points = vgui.Create("DNumberWang", frame)
  97.         bus_points:SetPos(70, initial)
  98.         bus_points:SetValue(infos["busPoints"])
  99.         bus_points:SetSize(25, 15)
  100.         bus_points:SetMinMax(0, 12)
  101.         bus_points:SetDecimals(0)
  102.         local bus_label_points = vgui.Create("DLabel", frame)
  103.         bus_label_points:SetPos(97, initial - 3)
  104.         bus_label_points:SetText("Points")
  105.         initial = initial + 20
  106.         bus_checkbox.OnChange = function()
  107.             if (bus_checkbox:GetChecked()) then
  108.                 bus_points:SetValue(12)
  109.             else
  110.                 bus_points:SetValue(0)
  111.             end
  112.         end
  113.     end
  114.    
  115.     if infos["truck"] then
  116.         truck_checkbox = vgui.Create("DCheckBox", frame)
  117.         truck_checkbox:SetPos(5, initial)
  118.         truck_checkbox:SetValue(infos["truck"])
  119.         local truck_label = vgui.Create("DLabel", frame)
  120.         truck_label:SetPos(22, initial - 3)
  121.         truck_label:SetText("Camion")
  122.         truck_points = vgui.Create("DNumberWang", frame)
  123.         truck_points:SetPos(70, initial)
  124.         truck_points:SetValue(infos["truckPoints"])
  125.         truck_points:SetSize(25, 15)
  126.         truck_points:SetMinMax(0, 12)
  127.         truck_points:SetDecimals(0)
  128.         local truck_label_points = vgui.Create("DLabel", frame)
  129.         truck_label_points:SetPos(97, initial - 3)
  130.         truck_label_points:SetText("Points")
  131.         initial = initial + 20
  132.         truck_checkbox.OnChange = function()
  133.             if (truck_checkbox:GetChecked()) then
  134.                 truck_points:SetValue(12)
  135.             else
  136.                 truck_points:SetValue(0)
  137.             end
  138.         end
  139.     end
  140.    
  141.     if infos["carInstructor"] then
  142.         local instructor_label = vgui.Create("DLabel", frame)
  143.         instructor_label:SetPos(5, initial)
  144.         instructor_label:SetText("Instructeur:")
  145.         initial = initial + 20
  146.         car_instructor_checkbox = vgui.Create("DCheckBox", frame)
  147.         car_instructor_checkbox:SetPos(5, initial)
  148.         car_instructor_checkbox:SetValue(infos["carInstructor"])
  149.         local car_instructor_label = vgui.Create("DLabel", frame)
  150.         car_instructor_label:SetPos(22, initial - 3)
  151.         car_instructor_label:SetText("Voiture")
  152.         initial = initial + 20
  153.         bus_instructor_checkbox = vgui.Create("DCheckBox", frame)
  154.         bus_instructor_checkbox:SetPos(5, initial)
  155.         bus_instructor_checkbox:SetValue(infos["busInstructor"])
  156.         local bus_instructor_label = vgui.Create("DLabel", frame)
  157.         bus_instructor_label:SetPos(22, initial - 3)
  158.         bus_instructor_label:SetText("Bus")
  159.         initial = initial + 20
  160.         truck_instructor_checkbox = vgui.Create("DCheckBox", frame)
  161.         truck_instructor_checkbox:SetPos(5, initial)
  162.         truck_instructor_checkbox:SetValue(infos["truckInstructor"])
  163.         local truck_instructor_label = vgui.Create("DLabel", frame)
  164.         truck_instructor_label:SetPos(22, initial - 3)
  165.         truck_instructor_label:SetText("Camion")
  166.         initial = initial + 20
  167.     end
  168.    
  169.     local submit_but = vgui.Create("DButton", frame)
  170.     submit_but:SetSize(125,15)
  171.     submit_but:SetPos(5,initial)
  172.     submit_but:SetText("Mettre à Jour")
  173.     submit_but.DoClick = function()
  174.         net.Start("instructor_info_menu")
  175.         net.WriteString(infos["name"])
  176.         if infos["car"] then
  177.             net.WriteString("car")
  178.             if(car_checkbox:GetValue()) then
  179.                 if(car_points:GetValue() <= 0) then
  180.                     net.WriteInt(0, 32)
  181.                     net.WriteInt(0, 32)
  182.                 elseif (car_points:GetValue() > 12) then
  183.                     net.WriteInt(1, 32)
  184.                     net.WriteInt(12, 32)
  185.                 else
  186.                     net.WriteInt(1, 32)
  187.                     net.WriteInt(car_points:GetValue(), 32)
  188.                 end
  189.             else
  190.             net.WriteInt(0, 32)
  191.             net.WriteInt(0, 32)
  192.             end
  193.         end
  194.         if infos["bus"] then
  195.             net.WriteString("bus")
  196.             if(bus_checkbox:GetValue()) then
  197.                 if(bus_points:GetValue() <= 0) then
  198.                     net.WriteInt(0, 32)
  199.                     net.WriteInt(0, 32)
  200.                 elseif (bus_points:GetValue() > 12) then
  201.                     net.WriteInt(1, 32)
  202.                     net.WriteInt(12, 32)
  203.                 else
  204.                     net.WriteInt(1, 32)
  205.                     net.WriteInt(bus_points:GetValue(), 32)
  206.                 end
  207.             else
  208.                 net.WriteInt(0, 32)
  209.                 net.WriteInt(0, 32)
  210.             end
  211.         end
  212.         if infos["truck"] then
  213.             net.WriteString("truck")
  214.             if(truck_checkbox:GetValue()) then
  215.                 if(truck_points:GetValue() <= 0) then
  216.                     net.WriteInt(0, 32)
  217.                     net.WriteInt(0, 32)
  218.                 elseif (truck_points:GetValue() > 12) then
  219.                     net.WriteInt(1, 32)
  220.                     net.WriteInt(12, 32)
  221.                 else
  222.                     net.WriteInt(1, 32)
  223.                     net.WriteInt(truck_points:GetValue(), 32)
  224.                 end
  225.             else
  226.                 net.WriteInt(0, 32)
  227.                 net.WriteInt(0, 32)
  228.             end
  229.         end
  230.         if infos["carInstructor"] then
  231.             net.WriteString("instructors")
  232.             if car_instructor_checkbox:GetValue() then
  233.                 net.WriteInt(1, 32)
  234.             else
  235.                 net.WriteInt(0, 32)
  236.             end
  237.             if bus_instructor_checkbox:GetValue() then
  238.                 net.WriteInt(1, 32)
  239.             else
  240.                 net.WriteInt(0, 32)
  241.             end
  242.             if truck_instructor_checkbox:GetValue() then
  243.                 net.WriteInt(1, 32)
  244.             else
  245.                 net.WriteInt(0, 32)
  246.             end
  247.         end
  248.         net.WriteString("fin")
  249.         net.SendToServer()
  250.         frame:Close()
  251.     end
  252. end
  253. net.Receive("instructor_info_menu", DrawInfoGUI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement