CapsAdmin

Untitled

Mar 16th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.17 KB | None | 0 0
  1. if (SERVER) then
  2.         resource.AddFile("materials/entities/sent_nametag.png");
  3. end;
  4.  
  5. AddCSLuaFile();
  6.  
  7. ENT.Type = "anim";
  8. ENT.PrintName = "nametag";
  9. ENT.Author = "Chessnut";
  10. ENT.Information = "touch";
  11. ENT.Category = "tag";
  12. ENT.Spawnable = true;
  13.  
  14. function ENT:Draw()
  15.     self:DrawModel()
  16.    
  17.     local ply = self:GetOwner()
  18.    
  19.     if not ply:IsValid() then return end
  20.    
  21.     local nick = ply:Nick()
  22.     local pos = self:GetPos()
  23.     local ang = self:GetAngles()
  24.    
  25.     ang:RotateAroundAxis(self:GetUp(), 180)
  26.     pos = pos + ang:Up()
  27.    
  28.     cam.Start3D(EyePos(), EyeAngles())
  29.         cam.Start3D2D(pos, ang, 0.3)
  30.             surface.SetFont("DermaDefault")
  31.             surface.SetTextColor(color_white)
  32.             local w, h = surface.GetTextSize(nick)
  33.             surface.SetTextPos(-w/2,-h/2)
  34.             surface.DrawText(nick)
  35.         cam.End3D2D()  
  36.     cam.End3D()    
  37. end
  38.  
  39. function ENT:SetupDataTables()
  40.     self:NetworkVar("Int", 0, "Thrust");
  41.     self:NetworkVar("Int", 0, "DamageAmount");
  42. end;
  43.  
  44. function ENT:SpawnFunction(client, trace)
  45.     if (!trace.Hit) then
  46.         return;
  47.     end;
  48.  
  49.     if ( (client.nextnametag or 0) < CurTime() ) then
  50.         if ( IsValid(client.nametag) ) then
  51.             client.nametag:Remove();
  52.         end;
  53.         local entity = ents.Create(self.ClassName);
  54.         entity:SetPos( client:LocalToWorld( client:OBBCenter() ) );
  55.         entity:SetOwner(client);
  56.         entity:SetCollisionGroup(COLLISION_GROUP_DEBRIS);
  57.         entity:Spawn();
  58.         entity:Activate();
  59.         entity:SetMaterial ("models/shiny")
  60.         client.nametag = entity;
  61.         return entity;
  62.     else
  63.         client:ChatPrint("You cannot get another nametag yet!");
  64.     end;
  65. end;
  66.  
  67. function ENT:Initialize()
  68.     if (CLIENT) then
  69.     local pos = self:GetPos();
  70.     local owner = self:GetOwner();
  71.     local texttext = ents.CreateClientProp( "models/hunter/blocks/cube025x025x025.mdl" )
  72.     texttext:SetModel( "models/hunter/blocks/cube025x025x025.mdl" )
  73.     texttext:SetSolid(SOLID_BBOX);
  74.     texttext:SetMoveType(MOVETYPE_VPHYSICS);
  75.     texttext:PhysicsInit(SOLID_BBOX);
  76.     texttext:Health(5)
  77.     texttext:DrawShadow( false )
  78.     texttext:SetPos(owner:GetPos())
  79.     texttext:SetAngles(Angle(0,0,0))
  80.  
  81.     function texttext:RenderOverride()
  82.     if CLIENT then
  83.         cam.Start3D(EyePos(), EyeAngles())
  84.             cam.Start3D2D(self:GetPos(), self:GetAngles(), 0.5)
  85.                 surface.SetFont("DermaDefault")
  86.                 surface.SetTextColor(color_black)
  87.                 surface.SetTextPos(0,0)
  88.                 surface.DrawText( "비욘세" )
  89.             cam.End3D2D()  
  90.         cam.End3D()    
  91.     end
  92.     end
  93.     texttext:RenderOverride()
  94.     texttext.mbox = 1
  95.     end
  96.     if SERVER then
  97.         self:SetModel("models/props_lab/harddrive02.mdl");
  98.         self:SetNotSolid(SOLID_BBOX);
  99.         self:SetMoveType(MOVETYPE_VPHYSICS);
  100.         self:PhysicsInit(SOLID_BBOX);
  101.         self:SetUseType(SIMPLE_USE);
  102.         self:Health(5)
  103.         self:DrawShadow( false )
  104.        
  105.         local physicsObject = self:GetPhysicsObject();
  106.  
  107.         if ( IsValid(physicsObject) ) then
  108.             physicsObject:Wake();
  109.             physicsObject:EnableMotion(true);
  110.         end;
  111.     end;
  112. self.CrateHealth = 5
  113. self.mbox = 1
  114. end;
  115.  
  116. function ENT:OnTakeDamage(Damage)
  117.     self.CrateHealth = self.CrateHealth - Damage:GetDamage()
  118.  
  119.     if self.CrateHealth <= 0 then
  120.        self:RemoveIt()
  121.        texttext:RemoveIt()
  122.     end
  123. end
  124.  
  125. function ENT:RemoveIt()
  126.     local pos = self.Entity:GetPos()
  127.     local Choose = math.random(1, 1)
  128.     local owner = self:GetOwner(); 
  129.     local all = player.GetAll()
  130.     self:Remove()
  131.     self:EmitSound( "beyonceout.wav",0,100)
  132.     texttext:Remove()
  133.     local Random = ents.Create("prop_physics")
  134.     Random:SetModel("models/props_junk/wood_crate002a.mdl")
  135.     Random:SetPos(pos);
  136.     Random:Spawn()
  137.     Random:Fire("break","",0)
  138.     owner:Kill()
  139. end
  140.  
  141. function ENT:Think()
  142.     local owner = self:GetOwner();
  143.     if ( !IsValid(owner) ) then
  144.         if SERVER then self:Remove(); end
  145.  
  146.         return;
  147.     end;
  148.  
  149.     local bone = owner:LookupBone("ValveBiped.Bip01_Spine2");
  150.  
  151.     if (bone) then
  152.         local position, angles = owner:GetBonePosition(bone);
  153.  
  154.         angles:RotateAroundAxis(angles:Forward(), 90);
  155.         angles:RotateAroundAxis(angles:Right(), 360);
  156.         angles:RotateAroundAxis(angles:Up(), 90);
  157.        
  158.         self:SetPos( position + (angles:Up() * 15) + (angles:Forward() * 0) + (angles:Right() * -0) );
  159.         self:SetAngles(angles);
  160.         local scale = Vector( 1,1.4,0.1 )
  161.         local mat = Matrix()
  162.         mat:Scale( scale )
  163.    
  164.     if CLIENT then
  165.         self:EnableMatrix( "RenderMultiply", mat )
  166.     end
  167.     end;
  168. end;
Advertisement
Add Comment
Please, Sign In to add comment