Python1320

Untitled

Jul 8th, 2010
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.90 KB | None | 0 0
  1. local ENT={}
  2.  
  3. ENT.Type            = "anim"
  4. ENT.Base            = "base_anim"
  5. ENT.PrintName       = ""
  6. ENT.Author          = ""
  7.  
  8. ENT.Spawnable           = false
  9. ENT.AdminSpawnable      = ENT.AdminSpawnable
  10.  
  11.  
  12. ENT.RenderGroup         = RENDERGROUP_TRANSLUCENT
  13.  
  14. ENT.Base = "base_anim"
  15. ENT.Type = "anim"
  16.  
  17.  
  18. ENT.Width = 256
  19. ENT.Height = 128
  20. ENT.Scale = 0.5
  21.  
  22.  
  23. local function RayQuadIntersect(vOrigin, vDirection, vPlane, vX, vY)
  24.         local vp = vDirection:Cross(vY)
  25.  
  26.  
  27.         local d = vX:DotProduct(vp)
  28.  
  29.  
  30.         if (d <= 0.0) then return end
  31.  
  32.  
  33.         local vt = vOrigin - vPlane
  34.         local u = vt:DotProduct(vp)
  35.         if (u < 0.0 or u > d) then return end
  36.  
  37.  
  38.         local v = vDirection:DotProduct(vt:Cross(vX))
  39.         if (v < 0.0 or v > d) then return end
  40.  
  41.  
  42.         return Vector(u / d, v / d, 0)
  43. end
  44.  
  45.  
  46. function ENT:Initialize()
  47.     motd = self
  48.  
  49.     if SERVER then
  50.    
  51.         self.Entity:SetModel( "models/props_interiors/BathTub01a.mdl" )
  52.  
  53.         self.Entity:SetNotSolid(true)
  54.  
  55.  
  56.         self:SetAngles(Angle(0,180,0))
  57.         self:SetNWString('place',self.place)
  58.        
  59.        
  60.     else
  61.    
  62.            self.HTML = vgui.Create("HTML")  
  63.         self.HTML:SetSize( 128,128 )  
  64.         self.HTML:SetPaintedManually( true )  
  65.      
  66.         self.HTML:OpenURL( "http://whatismyip.com" )  
  67.    
  68.         local min = Vector(0, (-self.Width/2) * self.Scale, 0)
  69.         local max = Vector(0, (self.Width/2) * self.Scale, self.Height*self.Scale)
  70.  
  71.  
  72.         self:SetRenderBounds(min, max)
  73.  
  74.         self.mX, self.mY = 0, 0
  75.     end
  76.  
  77.  
  78.     self:DrawShadow(false)
  79. end
  80.  
  81. function ENT:DrawMOTD()
  82.  
  83. /*  surface.SetDrawColor( 40, 40, 40, 100)
  84.     surface.DrawRect(0 , 0, width, height )
  85.     draw.DrawText("The time is now "..os.time(), "Default", self.Width/2, 20, Color(150, 180, 200, 255), TEXT_ALIGN_CENTER )
  86.    
  87.     draw.DrawText("The time is now "..os.date(), "Default", self.Width/2, 50, Color(150, 180, 200, 255), TEXT_ALIGN_CENTER )
  88.    
  89.     draw.DrawText("Welcome to Meta-Construct Build Server, "..LocalPlayer():GetName(), "Default", 10, 5, Color(150, 180, 200, 255), TEXT_ALIGN_LEFT ) */
  90. end
  91.  
  92. function ENT:Think()
  93.  
  94.     self.HTMLMat = self.HTML and self.HTML:GetHTMLMaterial()  
  95.  
  96.     self:NextThink(CurTime() + 0.1)
  97.  
  98. end
  99.  
  100. local width, height
  101.  
  102. function ENT:Draw()
  103.        
  104.  
  105.  
  106.         local pos, ang = self:GetPos(), self:GetAngles()
  107.  
  108.         ang:RotateAroundAxis(ang:Up(), 0)
  109.         ang:RotateAroundAxis(ang:Forward(), 90)
  110.  
  111.    
  112.         pos=pos-self:GetAngles():Forward()*(self.Width/2)*(1/self.Scale)/2
  113.         pos=pos-self:GetAngles():Up()*-(self.Height/2)*(1/self.Scale)/2
  114.    
  115.         width = self.Width*(1/self.Scale)
  116.         height = self.Height*(1/self.Scale)
  117.        
  118.         if !self.HTML || !self.HTMLMat then return end  
  119.         cam.Start3D(EyePos(), EyeAngles()) --dunno
  120.         render.SetMaterial(self.HTMLMat)
  121.         render.DrawQuadEasy(pos, Vector(0,1,0), width, height, color_white, 180)
  122.         cam.End3D()
  123. end
  124.  
  125. function ENT:OnRemove()
  126.     if !self.HTML then
  127.         self.HTML:Remove()
  128.     end
  129. end
  130.  
  131. scripted_ents.Register(ENT, "lua_motd", true)
  132.  
  133. game.CleanUpMap()
Add Comment
Please, Sign In to add comment