Mathilde411

instructor_menu server

Jul 21st, 2017
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.20 KB | None | 0 0
  1. util.AddNetworkString("instructor_menu")
  2. util.AddNetworkString("instructor_info_menu")
  3.  
  4. hook.Add("PlayerSay", "InstructorCommand", function(ply, txt, chn)
  5.     if (string.sub(string.lower(txt), 1, 11) == "!instructor" and (ULib.ucl.query(ply, "license admin panel") or ply.carInstructor == 1 or ply.busInstructor == 1 or ply.truckInstructor == 1)) then
  6.         net.Start("instructor_menu")
  7.         net.Send(ply)
  8.         return ""
  9.     end
  10. end)
  11.  
  12. net.Receive("instructor_menu", function(len, ply)
  13.         if(IsValid(ply) and ply:IsPlayer() and ((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel") or ply.carInstructor == 1 or ply.busInstructor == 1 or ply.truckInstructor == 1)) then
  14.             local txt = net.ReadString();
  15.             local choice = nil;
  16.             for k, v in pairs(player.GetAll()) do
  17.                 if(string.lower(tostring(v:Name())) == string.lower(txt)) then
  18.                     choice = v
  19.                     break
  20.                 end
  21.             end
  22.             if not choice then return end
  23.             local infos = {}
  24.             infos["name"] =  choice:Name();
  25.             if((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel") or (ply.carInstructor == 1 and choice.carInstructor ~= 1)) then
  26.                 infos["car"] = choice.carLicense
  27.                 infos["carPoints"] = choice.carLicensePoints
  28.             end
  29.             if((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel") or (ply.busInstructor == 1 and choice.busInstructor ~= 1)) then
  30.                 infos["bus"] = choice.busLicense
  31.                 infos["busPoints"] = choice.busLicensePoints
  32.             end
  33.             if((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel") or (ply.truckInstructor == 1 and choice.truckInstructor ~= 1)) then
  34.                 infos["truck"] = choice.truckLicense
  35.                 infos["truckPoints"] = choice.truckLicensePoints
  36.             end
  37.             if((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel")) then
  38.                 infos["carInstructor"] = choice.carInstructor
  39.                 infos["busInstructor"] = choice.busInstructor
  40.                 infos["truckInstructor"] = choice.truckInstructor
  41.             end
  42.             net.Start("instructor_info_menu")
  43.             net.WriteTable(infos)
  44.             net.Send(ply)
  45.         end
  46.     end)
  47.    
  48. net.Receive("instructor_info_menu", function(len, ply)
  49.     if(IsValid(ply) and ply:IsPlayer() and ((not ULib and ply:IsAdmin()) or ULib.ucl.query(ply, "license admin panel") or ply.carInstructor == 1 or ply.busInstructor == 1 or ply.truckInstructor == 1)) then
  50.             local txt = net.ReadString()
  51.             local choice = nil
  52.             for k, v in pairs(player.GetAll()) do
  53.                 if(string.lower(tostring(v:Name())) == string.lower(txt)) then
  54.                     choice = v
  55.                     break
  56.                 end
  57.             end
  58.             if not choice then return end
  59.             local key = ""
  60.             while(true) do
  61.                 key = net.ReadString()
  62.                 if(key == "fin") then
  63.                     break;
  64.                 elseif(key == "car") then
  65.                     carl = net.ReadInt()
  66.                     choice.carLicense = net.ReadInt()
  67.                     choice.carLicensePoints = net.ReadInt()
  68.                 elseif(key == "bus") then
  69.                     choice.busLicense = net.ReadInt()
  70.                     choice.busLicensePoints = net.ReadInt()
  71.                 elseif(key == "truck") then
  72.                     choice.truckLicense = net.ReadInt()
  73.                     choice.truckLicensePoints = net.ReadInt()
  74.                 elseif(key == "instructors") then
  75.                     choice.carInstructor = net.ReadInt()
  76.                     choice.busInstructor = net.ReadInt()
  77.                     choice.truckInstructor = net.ReadInt()
  78.                 end
  79.             end
  80.         end
  81.     end)
Advertisement
Add Comment
Please, Sign In to add comment