Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. ENT.Type = "anim"
  2. ENT.PrintName       = "Spawnable Box"
  3. ENT.Author          = "CGHippo"
  4. ENT.Contact         = "Don't"
  5. ENT.Purpose         = "Get health"
  6. ENT.Instructions    = "Press E on me!"
  7.  
  8. function ENT:Think()
  9.     local pos = self:GetPos()
  10.     local curve = math.abs(math.sin( CurTime() * 25 )) * 25  -- x = speed. Higher the number, the faster the motion. y = size. Higher the number, the bigger the change in position.
  11.     self:SetPos( Vector(pos.x,pos.y,curve) )
  12.  
  13.     self:NextThink( CurTime() )
  14.     return true
  15. end
  16.  
  17. -- SHARED.LUA ABOVE --
  18.  
  19. AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
  20. AddCSLuaFile( "shared.lua" )  -- and shared scripts are sent.
  21. AddCSLuaFile( "init.lua" )
  22.  
  23. include( "shared.lua" )
  24.  
  25. function ENT:Initialize()
  26.  
  27.     self:SetModel( "models/dav0r/hoverball.mdl" )
  28.     self:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
  29.     self:SetMoveType( MOVETYPE_FLYGRAVITY )   -- after all, gmod is a physics
  30.     self:SetSolid( SOLID_VPHYSICS )         -- Toolbox
  31.  
  32.     local phys = self:GetPhysicsObject()
  33.     if (phys:IsValid()) then
  34.         phys:Wake()
  35.     end
  36. end
  37.  
  38. function ENT:Use( activator, caller )
  39.     if ( activator:IsPlayer() ) then
  40.         activator:SetHealth( 150 )
  41.         self:Remove()
  42.     end
  43. end
  44.  
  45. function ENT:Think()
  46.     -- We don't need to think, we are just a prop after all!
  47. end
  48.  
  49. -- INIT.LUA ABOVE --
  50.  
  51. include('shared.lua')
  52.  
  53. local rotate = {}
  54.  
  55. function ENT:Draw()
  56.         //Drawing the model
  57.     self:DrawModel()
  58.     local ang = self:GetAngles()
  59.  
  60.     cam.Start3D2D( self:GetPos(), ang, .5 )
  61.         draw.RoundedBox( 1, -25, 25, 50, 20, Color(35, 35, 35, 255) )
  62.     cam.End3D2D()
  63.  
  64.     cam.Start3D2D( self:GetPos(), Angle( 0, -90, 90 ), .5 )
  65.         draw.DrawText( "Press E on me!", "TargetID", 0, 0, Color( 255, 255, 255, 255 ) )   
  66.     cam.End3D2D()
  67.  
  68. end
  69.  
  70. -- CL_INIT.LUA ABOVE --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement