Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- feeconfig={}
- feeconfig.BallName = "Super Football Easter Egg"
- feeconfig.BallModel = "models/m_pump/m_pump.mdl"
- feeconfig.HUDSizeX = 200
- feeconfig.HUDSizeY = 40
- feeconfig.HUDPosY = 20
- feeconfig.HUDPosX = 40
- feeconfig.SpawnDelay = 120 --s
- feeconfig.nextSpawn = CurTime()
- feeconfig.timer = 0
- if CLIENT then
- surface.CreateFont( "EasterEggFont", {
- font = "Trebuchet24", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
- extended = false,
- size = 13,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = false,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false,
- } )
- surface.CreateFont( "EasterEggFontTop", {
- font = "DermaLarge", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
- extended = false,
- size = 30,
- weight = 500,
- blursize = 0,
- scanlines = 0,
- antialias = true,
- underline = false,
- italic = false,
- strikeout = true,
- symbol = false,
- rotary = false,
- shadow = false,
- additive = false,
- outline = false,
- } )
- end
- if SERVER then
- local vectors = {}
- if !sql.TableExists( "gmod_eastereggs") then
- sql.Query( "CREATE TABLE gmod_eastereggs ( player_id string, count int, name string )" )
- end
- --------------------------------Add Points--------------------------------
- function AddEasterEggs(ply)
- print("adding easter to "..ply:GetName())
- local PlyID = ply:SteamID()
- local table = sql.Query("SELECT * FROM gmod_eastereggs WHERE player_id = '" .. PlyID .. "'")
- if table == nil then
- print("not alreadty")
- print()
- sql.Query("INSERT INTO gmod_eastereggs(player_id, count,name) VALUES ('" .. PlyID .. "',1, '"..ply:GetName().."')")
- ply:SetNWInt("EasterEgg",1)
- else
- print(table[1]["count"]+1)
- sql.Query("UPDATE gmod_eastereggs SET count ='".. tostring(table[1]["count"]+1) .."',name = '"..ply:GetName().."' WHERE player_id = '" .. PlyID .. "'")
- ply:SetNWInt("EasterEgg",table[1]["count"]+1)
- end
- end
- hook.Add("PlayerAuthed", "EasterEggDatabaseTest", function(ply)
- local table = sql.Query("SELECT * FROM gmod_eastereggs WHERE player_id = '" .. ply:SteamID() .. "'")
- if table == nil then
- sql.Query("INSERT INTO gmod_eastereggs(player_id, count, name) VALUES ('" .. ply:SteamID() .. "',0, '"..ply:GetName().."')")
- ply:SetNWInt("EasterEgg",0)
- print("Creating " .. ply:GetName() .. " in the database.")
- else
- ply:SetNWInt("EasterEgg",tonumber(table[1]["count"]))
- print("Player " .. ply:GetName() .. " is already in the database he got now " .. table[1]["count"])
- end
- end)
- --------------------------------Hook for taking easter--------------------------------
- hook.Add("EasterEggFound", "SomeoneFoundAnEasterEgg", function(ply)
- AddEasterEggs(ply)
- PrintMessage(4,ply:GetName().." have found an ECHO! He has found ".. ply:GetNWInt("EasterEgg") .. " so far!")
- end)
- --------------------------------Hook set Player Count--------------------------------
- end
- if CLIENT then
- hook.Add("HUDPaint", "EasterEggCounter", function()
- surface.SetDrawColor(Color(0,0,0))
- surface.DrawRect(feeconfig.HUDSizeX,ScrH()-feeconfig.HUDSizeY,245,feeconfig.HUDSizeY)
- surface.SetDrawColor(Color(70,70,70))
- surface.DrawRect(feeconfig.HUDSizeX,ScrH()-feeconfig.HUDSizeY+5,250-10,feeconfig.HUDSizeY-10)
- surface.SetFont("Trebuchet24")
- surface.SetTextColor(255,255,255,255)
- local text = math.Round(feeconfig.nextSpawn-CurTime()).." Echo Spawn Time"
- surface.SetTextPos(feeconfig.HUDSizeX+250/2-surface.GetTextSize(text)/2,ScrH()-feeconfig.HUDSizeY/2-15)
- surface.DrawText(text)
- surface.SetDrawColor(Color(0,0,0))
- surface.DrawRect(0,ScrH()-feeconfig.HUDSizeY,feeconfig.HUDSizeX,feeconfig.HUDSizeY)
- surface.SetDrawColor(Color(70,70,70))
- surface.DrawRect(5+0,5+ScrH()-feeconfig.HUDSizeY,feeconfig.HUDSizeX-10,feeconfig.HUDSizeY-10)
- surface.SetFont("Trebuchet24")
- surface.SetTextColor(255,255,255,255)
- local text = LocalPlayer():GetNWInt("EasterEgg")
- if text != nil then text = text.." Echo founds"else text = "0 echo founds" end
- surface.SetTextPos(feeconfig.HUDSizeX/2-surface.GetTextSize(text)/2,ScrH()-feeconfig.HUDSizeY/2-15)
- surface.DrawText(text)
- end)
- end
- local vectors = {}
- if SERVER then
- util.AddNetworkString("OpenEASTERTOP")
- local text = file.Read("vectorseaster.txt", DATA)
- if text == nil then print("---------------------------EASTER EGG-------------------") print("NO VECTOR FILE IN DATA/vectorseaster.txt")return end
- local lines = string.Explode("\n",text)
- for k, v in pairs (lines) do
- if not string.StartWith(v," ") then
- local curline = string.Explode(" ", v)
- table.insert(vectors,Vector(curline[1],curline[2],curline[3]))
- end
- end
- end
- feeconfig.nextSpawn = CurTime()+feeconfig.SpawnDelay
- if SERVER then
- local entities = ents.FindByClass("football_easteregg")
- if entities!= nil then
- for eggindex,egg in pairs (entities) do
- if egg:IsValid() then egg:Remove() end
- end
- end
- PrintTable(vectors)
- for k,v in pairs(vectors) do
- local e = ents.Create("football_easteregg")
- if v !=nil then
- if e:IsValid() then
- e:SetPos(v)
- e:Initialize()
- e:Spawn()
- e:SetMoveType(MOVETYPE_NONE)
- e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
- end
- end
- end
- end
- timer.Create("SpawningEggTimer",feeconfig.SpawnDelay,0,function()
- feeconfig.nextSpawn = CurTime()+feeconfig.SpawnDelay
- if SERVER then
- local entities = ents.FindByClass("football_easteregg")
- if entities!= nil then
- for eggindex,egg in pairs (entities) do
- if egg:IsValid() then egg:Remove() end
- end
- end
- PrintTable(vectors)
- for k,v in pairs(vectors) do
- print("Creating egg")
- local e = ents.Create("football_easteregg")
- if v !=nil then
- if e:IsValid() then
- print("egg created")
- e:SetPos(v)
- e:Initialize()
- e:Spawn()
- e:SetMoveType(MOVETYPE_NONE)
- e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
- end
- end
- end
- end
- end)
- if SERVER then
- hook.Add( "PlayerSay", "EasterEGgscommands", function( ply, text, team )
- if text == "/spawneggs" then
- if ply:IsAdmin() then
- local entities = ents.FindByClass("football_easteregg")
- if entities!= nil then
- for eggindex,egg in pairs (entities) do
- if egg:IsValid() then egg:Remove() end
- end
- end
- for k,v in pairs(vectors) do
- print(v)
- print("Creating egg")
- local e = ents.Create("football_easteregg")
- if v !=nil then
- if e:IsValid() then
- print("egg created")
- e:SetPos(v)
- e:Initialize()
- e:Spawn()
- e:SetMoveType(MOVETYPE_NONE)
- e:SetColor(Color(math.random(0,255),math.random(0,255),math.random(0,255),255))
- end
- end
- end
- return ""
- end
- end
- if text == "/echo" then -- if the first four characters of the string are /all
- net.Start("OpenEASTERTOP")
- net.WriteTable(sql.Query("SELECT * FROM gmod_eastereggs"))
- net.Send(ply)
- return ""
- end
- end)
- end
- if CLIENT then
- local opened = 0
- for k,v in pairs(ents.GetAll()) do
- if v:GetClass() == "football_easteregg" then
- v:DrawModel()
- end
- end
- net.Receive("OpenEASTERTOP", function()
- if opened == 0 then
- local query = net.ReadTable()
- table.sort(query,function(a,b) return tonumber(a.count) > tonumber(b.count) end)
- opened = 1
- ------------------Main Frame-----------------------
- local frame = vgui.Create("DFrame")
- frame:SetSize(500,500)
- frame:SetPos(ScrW()/2-250,ScrH()/2-250)
- frame:MakePopup()
- frame.Paint = function(self,w,h)
- surface.SetDrawColor(50,50,50,255)
- surface.DrawRect(0,0,w,h)
- end
- ------------------Panel Close------------------
- local panclose = vgui.Create("DPanel",frame)
- panclose:SetSize(500,30)
- panclose:SetPos(0,0)
- panclose.Paint = function(self,w,h)
- surface.SetDrawColor(255,50,50,255)
- surface.DrawRect(0,0,w,h)
- surface.SetTextPos(0,0)
- surface.SetFont("Trebuchet24")
- surface.SetTextColor(255,255,255,255)
- surface.DrawText("Easter ECHO ScoreBoard")
- end
- ------------------Button Close------------------
- local button = vgui.Create("DButton", panclose)
- button:SetSize(20,20)
- button:SetText("")
- button:SetPos(500-30,5)
- button.Paint = function(self,w,h)
- surface.SetTextPos(4,-2.5)
- surface.SetFont("Trebuchet24")
- surface.SetTextColor(255,255,255,255)
- surface.DrawText("X")
- end
- button.DoClick = function() frame:Close() opened = 0 end
- ------------------Panel------------------
- local score = vgui.Create("DPanel",frame)
- score:SetSize(440,430)
- score:SetPos(30,50)
- score.Paint = function(self,w,h)
- surface.SetDrawColor(20,20,20,200)
- surface.DrawRect(0,0,w,h)
- surface.SetFont("EasterEggFontTop")
- surface.SetTextPos(220-surface.GetTextSize("Top 26")/2,10)
- surface.SetTextColor(255,255,255,255)
- surface.DrawText("Top 26")
- local playerlist = player.GetAll()
- local playerconnected = {}
- if query != nil then
- --local playerlist = ents.GetAll()
- local index = 1
- local plush = 0
- local plusw = 0
- for k=1,#query,1 do
- if k<=26 then
- surface.SetTextPos(25+plusw*200,70+plush*15)
- surface.SetFont("EasterEggFont")
- surface.SetTextColor(255,255,255,255)
- surface.DrawText(k..". ".. query[k].name .. " - " .. query[k].count .." ECHO")
- --surface.DrawText(k..". " .. "ALONGLONGNAMEDD-255eggs")
- plush = plush+1
- if k/13 == math.Round(k/13) then
- plusw = plusw+1
- plush = 0
- end
- k = k+1
- end
- end
- end
- surface.SetFont("EasterEggFontTop")
- local text = "You have found " .. LocalPlayer():GetNWInt("EasterEgg") .. " ECHO eggs."
- surface.SetTextPos(220-surface.GetTextSize(text)/2,350)
- surface.SetTextColor(255,255,255,255)
- surface.DrawText(text)
- end
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement