Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.42 KB | None | 0 0
  1. feeconfig={}
  2. feeconfig.BallName = "Super Football Easter Egg"
  3. feeconfig.BallModel = "models/m_pump/m_pump.mdl"
  4. feeconfig.HUDSizeX = 200
  5. feeconfig.HUDSizeY = 40
  6. feeconfig.HUDPosY = 20
  7. feeconfig.HUDPosX = 40
  8. feeconfig.SpawnDelay = 120 --s
  9. feeconfig.nextSpawn = CurTime()
  10. feeconfig.timer = 0
  11. if CLIENT then
  12.     surface.CreateFont( "EasterEggFont", {
  13.         font = "Trebuchet24", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
  14.         extended = false,
  15.         size = 13,
  16.         weight = 500,
  17.         blursize = 0,
  18.         scanlines = 0,
  19.         antialias = true,
  20.         underline = false,
  21.         italic = false,
  22.         strikeout = false,
  23.         symbol = false,
  24.         rotary = false,
  25.         shadow = false,
  26.         additive = false,
  27.         outline = false,
  28.     } )
  29.     surface.CreateFont( "EasterEggFontTop", {
  30.         font = "DermaLarge", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
  31.         extended = false,
  32.         size = 30,
  33.         weight = 500,
  34.         blursize = 0,
  35.         scanlines = 0,
  36.         antialias = true,
  37.         underline = false,
  38.         italic = false,
  39.         strikeout = true,
  40.         symbol = false,
  41.         rotary = false,
  42.         shadow = false,
  43.         additive = false,
  44.         outline = false,
  45.     } )
  46. end
  47. if SERVER then
  48.     local vectors = {}
  49.     if !sql.TableExists( "gmod_eastereggs") then
  50.         sql.Query( "CREATE TABLE gmod_eastereggs ( player_id string, count int, name string )" )
  51.     end
  52.     --------------------------------Add Points--------------------------------
  53.     function AddEasterEggs(ply)
  54.         print("adding easter to "..ply:GetName())
  55.         local PlyID = ply:SteamID()
  56.         local table = sql.Query("SELECT * FROM gmod_eastereggs WHERE player_id = '" .. PlyID .. "'")
  57.         if table == nil then
  58.             print("not alreadty")
  59.             print()
  60.             sql.Query("INSERT INTO gmod_eastereggs(player_id, count,name) VALUES ('" .. PlyID .. "',1, '"..ply:GetName().."')")
  61.             ply:SetNWInt("EasterEgg",1)
  62.         else
  63.             print(table[1]["count"]+1)
  64.             sql.Query("UPDATE gmod_eastereggs SET count ='".. tostring(table[1]["count"]+1) .."',name = '"..ply:GetName().."' WHERE player_id = '" .. PlyID .. "'")
  65.             ply:SetNWInt("EasterEgg",table[1]["count"]+1)
  66.         end
  67.     end
  68.     hook.Add("PlayerAuthed", "EasterEggDatabaseTest", function(ply)
  69.         local table = sql.Query("SELECT * FROM gmod_eastereggs WHERE player_id = '" .. ply:SteamID() .. "'")
  70.         if table == nil then
  71.             sql.Query("INSERT INTO gmod_eastereggs(player_id, count, name) VALUES ('" .. ply:SteamID() .. "',0, '"..ply:GetName().."')")
  72.             ply:SetNWInt("EasterEgg",0)
  73.             print("Creating " .. ply:GetName() .. " in the database.")
  74.         else
  75.             ply:SetNWInt("EasterEgg",tonumber(table[1]["count"]))
  76.             print("Player  " .. ply:GetName() .. " is already in the database he got now " .. table[1]["count"])
  77.         end
  78.     end)
  79.     --------------------------------Hook for taking easter--------------------------------
  80.     hook.Add("EasterEggFound", "SomeoneFoundAnEasterEgg", function(ply)
  81.         AddEasterEggs(ply)
  82.         PrintMessage(4,ply:GetName().." have found an ECHO! He has found ".. ply:GetNWInt("EasterEgg") .. " so far!")
  83.     end)
  84.     --------------------------------Hook set Player Count--------------------------------
  85. end
  86.  
  87. if CLIENT then
  88.     hook.Add("HUDPaint", "EasterEggCounter", function()
  89.             surface.SetDrawColor(Color(0,0,0))
  90.             surface.DrawRect(feeconfig.HUDSizeX,ScrH()-feeconfig.HUDSizeY,245,feeconfig.HUDSizeY)
  91.             surface.SetDrawColor(Color(70,70,70))
  92.             surface.DrawRect(feeconfig.HUDSizeX,ScrH()-feeconfig.HUDSizeY+5,250-10,feeconfig.HUDSizeY-10)
  93.            
  94.             surface.SetFont("Trebuchet24")
  95.             surface.SetTextColor(255,255,255,255)
  96.             local text = math.Round(feeconfig.nextSpawn-CurTime()).." Echo Spawn Time"
  97.             surface.SetTextPos(feeconfig.HUDSizeX+250/2-surface.GetTextSize(text)/2,ScrH()-feeconfig.HUDSizeY/2-15)
  98.             surface.DrawText(text)
  99.  
  100.             surface.SetDrawColor(Color(0,0,0))
  101.             surface.DrawRect(0,ScrH()-feeconfig.HUDSizeY,feeconfig.HUDSizeX,feeconfig.HUDSizeY)
  102.             surface.SetDrawColor(Color(70,70,70))
  103.             surface.DrawRect(5+0,5+ScrH()-feeconfig.HUDSizeY,feeconfig.HUDSizeX-10,feeconfig.HUDSizeY-10)
  104.  
  105.             surface.SetFont("Trebuchet24")
  106.             surface.SetTextColor(255,255,255,255)
  107.  
  108.             local text = LocalPlayer():GetNWInt("EasterEgg")
  109.             if text != nil then text = text.." Echo founds"else text = "0 echo founds" end 
  110.             surface.SetTextPos(feeconfig.HUDSizeX/2-surface.GetTextSize(text)/2,ScrH()-feeconfig.HUDSizeY/2-15)
  111.             surface.DrawText(text)
  112.         end)
  113. end
  114. local vectors = {}
  115. if SERVER then
  116.     util.AddNetworkString("OpenEASTERTOP")
  117.     local text = file.Read("vectorseaster.txt", DATA)
  118.     if text == nil then print("---------------------------EASTER EGG-------------------") print("NO VECTOR FILE IN DATA/vectorseaster.txt")return end
  119.     local lines = string.Explode("\n",text)
  120.     for k, v in pairs (lines) do
  121.         if not string.StartWith(v," ") then
  122.                 local curline = string.Explode(" ", v)
  123.                 table.insert(vectors,Vector(curline[1],curline[2],curline[3]))
  124.         end
  125.     end
  126. end
  127. feeconfig.nextSpawn = CurTime()+feeconfig.SpawnDelay
  128. if SERVER then
  129.                 local entities = ents.FindByClass("football_easteregg")
  130.                 if entities!= nil then
  131.                     for eggindex,egg in pairs (entities) do
  132.                         if egg:IsValid() then   egg:Remove() end
  133.  
  134.                     end
  135.                 end
  136.                                 PrintTable(vectors)
  137.                 for k,v in pairs(vectors) do
  138.                     local e = ents.Create("football_easteregg")
  139.                     if v !=nil then
  140.                         if e:IsValid() then
  141.                             e:SetPos(v)
  142.                             e:Initialize()
  143.                             e:Spawn()
  144.                             e:SetMoveType(MOVETYPE_NONE)
  145.                             e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
  146.                         end
  147.                     end
  148.                 end
  149. end
  150. timer.Create("SpawningEggTimer",feeconfig.SpawnDelay,0,function()
  151.     feeconfig.nextSpawn = CurTime()+feeconfig.SpawnDelay
  152.     if SERVER then
  153.                 local entities = ents.FindByClass("football_easteregg")
  154.                 if entities!= nil then
  155.                     for eggindex,egg in pairs (entities) do
  156.                         if egg:IsValid() then   egg:Remove() end
  157.  
  158.                     end
  159.                 end
  160.                                 PrintTable(vectors)
  161.                 for k,v in pairs(vectors) do
  162.                                       print("Creating egg")
  163.                     local e = ents.Create("football_easteregg")
  164.                     if v !=nil then
  165.                         if e:IsValid() then
  166.                                                     print("egg created")
  167.                             e:SetPos(v)
  168.                             e:Initialize()
  169.                             e:Spawn()
  170.                             e:SetMoveType(MOVETYPE_NONE)
  171.                             e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
  172.                         end
  173.                     end
  174.                 end
  175.     end
  176. end)
  177. if SERVER then
  178.     hook.Add( "PlayerSay", "EasterEGgscommands", function( ply, text, team )
  179.         if text == "/spawneggs" then
  180.             if ply:IsAdmin() then
  181.                 local entities = ents.FindByClass("football_easteregg")
  182.                 if entities!= nil then
  183.                     for eggindex,egg in pairs (entities) do
  184.                         if egg:IsValid() then   egg:Remove() end
  185.  
  186.                     end
  187.                 end
  188.                 for k,v in pairs(vectors) do
  189.                                         print(v)
  190.                                         print("Creating egg")
  191.                     local e = ents.Create("football_easteregg")
  192.                     if v !=nil then
  193.                         if e:IsValid() then
  194.                                                    print("egg created")
  195.                             e:SetPos(v)
  196.                             e:Initialize()
  197.                             e:Spawn()
  198.                             e:SetMoveType(MOVETYPE_NONE)
  199.                             e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
  200.                         end
  201.                     end
  202.                 end
  203.                 return ""
  204.             end
  205.         end
  206.         if text == "/echo" then -- if the first four characters of the string are /all
  207.             net.Start("OpenEASTERTOP")
  208.                             net.WriteTable(sql.Query("SELECT * FROM gmod_eastereggs"))
  209.             net.Send(ply)
  210.             return ""
  211.         end
  212.     end)
  213. end
  214.  
  215.  
  216. if CLIENT then
  217.     local opened = 0
  218.         for k,v in pairs(ents.GetAll()) do
  219.           if v:GetClass() == "football_easteregg" then
  220.               v:DrawModel()
  221.           end
  222.         end
  223.     net.Receive("OpenEASTERTOP", function()
  224.         if opened == 0 then
  225.         local query = net.ReadTable()
  226.         table.sort(query,function(a,b) return tonumber(a.count) > tonumber(b.count) end)
  227.             opened = 1
  228. ------------------Main Frame-----------------------
  229.             local frame = vgui.Create("DFrame")
  230.             frame:SetSize(500,500)
  231.             frame:SetPos(ScrW()/2-250,ScrH()/2-250)
  232.             frame:MakePopup()
  233.             frame.Paint = function(self,w,h)
  234.                 surface.SetDrawColor(50,50,50,255)
  235.                 surface.DrawRect(0,0,w,h)
  236.             end
  237.             ------------------Panel Close------------------
  238.             local panclose = vgui.Create("DPanel",frame)
  239.             panclose:SetSize(500,30)
  240.             panclose:SetPos(0,0)
  241.             panclose.Paint = function(self,w,h)
  242.                 surface.SetDrawColor(255,50,50,255)
  243.                 surface.DrawRect(0,0,w,h)
  244.                 surface.SetTextPos(0,0)
  245.                 surface.SetFont("Trebuchet24")
  246.                 surface.SetTextColor(255,255,255,255)
  247.                 surface.DrawText("Easter ECHO ScoreBoard")
  248.             end
  249.             ------------------Button Close------------------
  250.             local button = vgui.Create("DButton", panclose)
  251.             button:SetSize(20,20)
  252.             button:SetText("")
  253.             button:SetPos(500-30,5)
  254.             button.Paint = function(self,w,h)
  255.                 surface.SetTextPos(4,-2.5)
  256.                 surface.SetFont("Trebuchet24")
  257.                 surface.SetTextColor(255,255,255,255)
  258.                 surface.DrawText("X")
  259.             end
  260.             button.DoClick = function() frame:Close() opened = 0 end
  261.  
  262.             ------------------Panel------------------
  263.             local score = vgui.Create("DPanel",frame)
  264.             score:SetSize(440,430)
  265.             score:SetPos(30,50)
  266.             score.Paint = function(self,w,h)
  267.                 surface.SetDrawColor(20,20,20,200)
  268.                 surface.DrawRect(0,0,w,h)
  269.                 surface.SetFont("EasterEggFontTop")
  270.                 surface.SetTextPos(220-surface.GetTextSize("Top 26")/2,10)
  271.                 surface.SetTextColor(255,255,255,255)
  272.                 surface.DrawText("Top 26")
  273.                 local playerlist = player.GetAll()
  274.                 local playerconnected = {}
  275.                 if query != nil then
  276.                     --local playerlist = ents.GetAll()
  277.                     local index = 1
  278.                     local plush = 0
  279.                     local plusw = 0
  280.                     for k=1,#query,1 do
  281.                         if k<=26 then
  282.                             surface.SetTextPos(25+plusw*200,70+plush*15)
  283.                             surface.SetFont("EasterEggFont")
  284.                             surface.SetTextColor(255,255,255,255)
  285.                             surface.DrawText(k..". ".. query[k].name .. " - " .. query[k].count .." ECHO")
  286.                             --surface.DrawText(k..". " .. "ALONGLONGNAMEDD-255eggs")
  287.                             plush = plush+1
  288.                             if k/13 == math.Round(k/13) then
  289.                                 plusw = plusw+1
  290.                                 plush = 0
  291.                             end
  292.                             k = k+1
  293.                         end
  294.                     end
  295.                 end
  296.                 surface.SetFont("EasterEggFontTop")
  297.                 local text = "You have found " .. LocalPlayer():GetNWInt("EasterEgg") .. " ECHO eggs."
  298.                 surface.SetTextPos(220-surface.GetTextSize(text)/2,350)
  299.                 surface.SetTextColor(255,255,255,255)
  300.                 surface.DrawText(text)
  301.             end
  302.         end
  303.     end)
  304. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement