Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function DrawGUI()
- local frame = vgui.Create("DFrame")
- frame:Center()
- frame:SetSize(140,80)
- frame:SetTitle("")
- frame:MakePopup()
- frame:ShowCloseButton(true)
- frame:SetDraggable( true )
- local player_select = vgui.Create("DComboBox", frame)
- player_select:SetPos(10, 30)
- player_select:SetSize(120, 20)
- player_select:SetText("Selectionnez un Joueur")
- for k, v in pairs(player.GetAll()) do
- player_select:AddChoice(tostring(v:Name()))
- end
- local submit_but = vgui.Create("DButton", frame)
- submit_but:SetSize(120,20)
- submit_but:SetPos(10,50)
- submit_but:SetText("Info")
- submit_but.DoClick = function()
- if(not player_select:GetValue() or player_select:GetValue() == "Selectionnez un Joueur") then return end
- frame:Close()
- net.Start("instructor_menu")
- net.WriteString(player_select:GetValue())
- net.SendToServer()
- end
- end
- net.Receive("instructor_menu", DrawGUI)
- local function DrawInfoGUI()
- local car_checkbox = nil
- local bus_checkbox = nil
- local truck_checkbox = nil
- local car_points = nil
- local bus_points = nil
- local truck_points = nil
- local car_instructor_checkbox = nil
- local bus_instructor_checkbox = nil
- local truck_instructor_checkbox = nil
- local infos = net.ReadTable()
- local tabs = 0
- if infos["car"] then tabs = tabs + 1 end
- if infos["bus"] then tabs = tabs + 1 end
- if infos["truck"] then tabs = tabs + 1 end
- if infos["carInstructor"] then tabs = tabs + 2 end
- if tabs == 0 then return end
- local frame = vgui.Create("DFrame")
- frame:Center()
- frame:SetSize(135, 200)
- frame:SetTitle(infos["name"])
- frame:MakePopup()
- frame:ShowCloseButton(true)
- frame:SetDraggable( true )
- local main_label = vgui.Create("DLabel", frame)
- main_label:SetPos(5, 20)
- main_label:SetText("Permis:")
- local initial = 40
- if infos["car"] then
- car_checkbox = vgui.Create("DCheckBox", frame)
- car_checkbox:SetPos(5, initial)
- car_checkbox:SetValue(infos["car"])
- local car_label = vgui.Create("DLabel", frame)
- car_label:SetPos(22, initial - 3)
- car_label:SetText("Voiture")
- car_points = vgui.Create("DNumberWang", frame)
- car_points:SetPos(70, initial)
- car_points:SetValue(infos["carPoints"])
- car_points:SetSize(25, 15)
- car_points:SetMinMax(0, 12)
- car_points:SetDecimals(0)
- local car_label_points = vgui.Create("DLabel", frame)
- car_label_points:SetPos(97, initial - 3)
- car_label_points:SetText("Points")
- initial = initial + 20
- car_checkbox.OnChange = function()
- if (car_checkbox:GetChecked()) then
- car_points:SetValue(12)
- else
- car_points:SetValue(0)
- end
- end
- end
- if infos["bus"] then
- bus_checkbox = vgui.Create("DCheckBox", frame)
- bus_checkbox:SetPos(5, initial)
- bus_checkbox:SetValue(infos["bus"])
- local bus_label = vgui.Create("DLabel", frame)
- bus_label:SetPos(22, initial - 3)
- bus_label:SetText("Bus")
- bus_points = vgui.Create("DNumberWang", frame)
- bus_points:SetPos(70, initial)
- bus_points:SetValue(infos["busPoints"])
- bus_points:SetSize(25, 15)
- bus_points:SetMinMax(0, 12)
- bus_points:SetDecimals(0)
- local bus_label_points = vgui.Create("DLabel", frame)
- bus_label_points:SetPos(97, initial - 3)
- bus_label_points:SetText("Points")
- initial = initial + 20
- bus_checkbox.OnChange = function()
- if (bus_checkbox:GetChecked()) then
- bus_points:SetValue(12)
- else
- bus_points:SetValue(0)
- end
- end
- end
- if infos["truck"] then
- truck_checkbox = vgui.Create("DCheckBox", frame)
- truck_checkbox:SetPos(5, initial)
- truck_checkbox:SetValue(infos["truck"])
- local truck_label = vgui.Create("DLabel", frame)
- truck_label:SetPos(22, initial - 3)
- truck_label:SetText("Camion")
- truck_points = vgui.Create("DNumberWang", frame)
- truck_points:SetPos(70, initial)
- truck_points:SetValue(infos["truckPoints"])
- truck_points:SetSize(25, 15)
- truck_points:SetMinMax(0, 12)
- truck_points:SetDecimals(0)
- local truck_label_points = vgui.Create("DLabel", frame)
- truck_label_points:SetPos(97, initial - 3)
- truck_label_points:SetText("Points")
- initial = initial + 20
- truck_checkbox.OnChange = function()
- if (truck_checkbox:GetChecked()) then
- truck_points:SetValue(12)
- else
- truck_points:SetValue(0)
- end
- end
- end
- if infos["carInstructor"] then
- local instructor_label = vgui.Create("DLabel", frame)
- instructor_label:SetPos(5, initial)
- instructor_label:SetText("Instructeur:")
- initial = initial + 20
- car_instructor_checkbox = vgui.Create("DCheckBox", frame)
- car_instructor_checkbox:SetPos(5, initial)
- car_instructor_checkbox:SetValue(infos["carInstructor"])
- local car_instructor_label = vgui.Create("DLabel", frame)
- car_instructor_label:SetPos(22, initial - 3)
- car_instructor_label:SetText("Voiture")
- initial = initial + 20
- bus_instructor_checkbox = vgui.Create("DCheckBox", frame)
- bus_instructor_checkbox:SetPos(5, initial)
- bus_instructor_checkbox:SetValue(infos["busInstructor"])
- local bus_instructor_label = vgui.Create("DLabel", frame)
- bus_instructor_label:SetPos(22, initial - 3)
- bus_instructor_label:SetText("Bus")
- initial = initial + 20
- truck_instructor_checkbox = vgui.Create("DCheckBox", frame)
- truck_instructor_checkbox:SetPos(5, initial)
- truck_instructor_checkbox:SetValue(infos["truckInstructor"])
- local truck_instructor_label = vgui.Create("DLabel", frame)
- truck_instructor_label:SetPos(22, initial - 3)
- truck_instructor_label:SetText("Camion")
- initial = initial + 20
- end
- local submit_but = vgui.Create("DButton", frame)
- submit_but:SetSize(125,15)
- submit_but:SetPos(5,initial)
- submit_but:SetText("Mettre à Jour")
- submit_but.DoClick = function()
- net.Start("instructor_info_menu")
- net.WriteString(infos["name"])
- if infos["car"] then
- net.WriteString("car")
- if(car_checkbox:GetValue()) then
- if(car_points:GetValue() <= 0) then
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- elseif (car_points:GetValue() > 12) then
- net.WriteInt(1, 32)
- net.WriteInt(12, 32)
- else
- net.WriteInt(1, 32)
- net.WriteInt(car_points:GetValue(), 32)
- end
- else
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- end
- end
- if infos["bus"] then
- net.WriteString("bus")
- if(bus_checkbox:GetValue()) then
- if(bus_points:GetValue() <= 0) then
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- elseif (bus_points:GetValue() > 12) then
- net.WriteInt(1, 32)
- net.WriteInt(12, 32)
- else
- net.WriteInt(1, 32)
- net.WriteInt(bus_points:GetValue(), 32)
- end
- else
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- end
- end
- if infos["truck"] then
- net.WriteString("truck")
- if(truck_checkbox:GetValue()) then
- if(truck_points:GetValue() <= 0) then
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- elseif (truck_points:GetValue() > 12) then
- net.WriteInt(1, 32)
- net.WriteInt(12, 32)
- else
- net.WriteInt(1, 32)
- net.WriteInt(truck_points:GetValue(), 32)
- end
- else
- net.WriteInt(0, 32)
- net.WriteInt(0, 32)
- end
- end
- if infos["carInstructor"] then
- net.WriteString("instructors")
- if car_instructor_checkbox:GetValue() then
- net.WriteInt(1, 32)
- else
- net.WriteInt(0, 32)
- end
- if bus_instructor_checkbox:GetValue() then
- net.WriteInt(1, 32)
- else
- net.WriteInt(0, 32)
- end
- if truck_instructor_checkbox:GetValue() then
- net.WriteInt(1, 32)
- else
- net.WriteInt(0, 32)
- end
- end
- net.WriteString("fin")
- net.SendToServer()
- frame:Close()
- end
- end
- net.Receive("instructor_info_menu", DrawInfoGUI)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement