Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. ENT.Type            = "anim"
  2. ENT.Base            = "base_gmodentity"
  3. ENT.PrintName       = "Fish"
  4. ENT.Author          = "Eryk"
  5. ENT.Information     = "This is a nice fish"
  6. ENT.Category        = "Fishing mod"
  7.  
  8. ENT.Spawnable       = false
  9.  
  10. ENT.RenderGroup     = RENDERGROUP_TRANSLUCENT
  11.  
  12. ENT.DeathTimer      = FISHINGMOD.Config.DeathTimer or 10 -- seconds
  13. ENT.Speed           = 5
  14. ENT.InWater         = true
  15. ENT.HasBaitInMouth  = false
  16.  
  17. function ENT:SetupDataTables()
  18.     self:NetworkVar( "Entity", 0, "FishSpot" )
  19.  
  20.     self:NetworkVar( "Int", 0, "SwimmingSpeed" )
  21.     self:NetworkVar( "Int", 1, "Size" )
  22.     self:NetworkVar( "Float", 3, "Tiredness" )
  23.     self:NetworkVar( "Bool", 0, "HasBaitInMouth" )
  24.     self:NetworkVar( "Vector", 0, "DirectionPos" )
  25.  
  26.     //For the client fish
  27.     self:NetworkVar( "Int", 2, "Speed" )
  28.     self:NetworkVar( "String", 0, "ClientsideModel")
  29.     self:NetworkVar( "String", 1, "FishName" )
  30.     self:NetworkVar( "Vector", 1, "CurrentPos" )
  31.   self:NetworkVar( "Bool", 1, "Death" )
  32. end
  33.  
  34. ENT.FISH = {}
  35.  
  36. local lang = FISHINGMOD.Language
  37.  
  38. function ENT.FISH:Draw()
  39.   self:DrawModel()
  40.  
  41.   local ply = LocalPlayer()
  42.  
  43.   local pos = self:GetPos()
  44.   local ang = self:GetAngles()
  45.  
  46.   local min = select(1, self:GetCollisionBounds())
  47.   local max = select(2, self:GetCollisionBounds())
  48.  
  49.   local len_height = math.sqrt(min.z^2 + max.z^2)
  50.  
  51.   if (len_height < 5) then len_height = 10 end
  52.  
  53.   if (ply:GetPos():Distance(pos) < 150) then
  54.     cam.Start3D2D(pos, Angle(-90, LocalPlayer():GetAngles().y, 0) - Angle(90, -90, 90), 0.025)
  55.  
  56.       surface.SetFont( "fishingmod_2d3d_font" )
  57.  
  58.       local name = lang:Translate(self:GetParent():GetFishName())
  59.  
  60.       local textposx, textposy = surface.GetTextSize(name)
  61.  
  62.       surface.SetDrawColor( 0, 0, 0, 230 )
  63.  
  64.       draw.RoundedBox( 32, -textposx * 1.5 - (-textposx * 1.5) / 2, len_height * -54, textposx * 1.5, 25 * 5, Color(25,25,25,200))
  65.  
  66.       surface.SetTextColor( 255, 255, 255, 255 )
  67.       surface.SetTextPos((textposx / 2) - textposx, len_height * -50 * 1.07)
  68.       surface.DrawText(name)
  69.  
  70.     cam.End3D2D()
  71.   end
  72. end
  73.  
  74. function ENT.FISH:RenderOverride()
  75.   self:Draw()
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement