Advertisement
TheDenVxUA

Untitled

Jul 31st, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.93 KB | None | 0 0
  1. AddCSLuaFile( "cl_init.lua" )
  2. AddCSLuaFile( "shared.lua" )
  3. include('shared.lua')
  4.  
  5. function ENT:SpawnFunction( Player, tr, Class )
  6.  
  7.     if ( !tr.Hit ) then return end
  8.  
  9.     local SpawnPos = tr.HitPos + tr.HitNormal* 20 + Vector(0,0,58)
  10.     local SpawnAng = Player:EyeAngles()
  11.     SpawnAng.p = 0
  12.     SpawnAng.y = SpawnAng.y + 180
  13.  
  14.     local ent = ents.Create( Class )
  15.     ent:SetPos( SpawnPos )
  16.     ent:SetAngles( SpawnAng )
  17.     ent:Spawn()
  18.     ent:Activate()
  19.    
  20.     return ent
  21.  
  22. end
  23.  
  24. function ENT:Initialize()
  25.     self.Entity:SetModel("models/tbfu_noticeboard/noticeboard.mdl")
  26.     self.Entity:PhysicsInit( SOLID_VPHYSICS )
  27.     self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
  28.     self.Entity:SetSolid( SOLID_VPHYSICS )
  29.     self.Entity:SetUseType( SIMPLE_USE )
  30.     self.Posters = {}
  31.    
  32.     self:GeneratePoses()
  33. end
  34.  
  35. function ENT:GeneratePoses()
  36.     self.PosterPoses = {}
  37.     self.PosterPoses.WPoses = {}
  38.     self.PosterPoses.Taken = {{},{}}
  39.     for i = -4, 5 do
  40.         table.insert(self.PosterPoses.WPoses,i * 12)
  41.     end
  42. end
  43.  
  44. function ENT:GenerateID(Poster)
  45.     local UpOrDown = math.random(1,2)
  46.     local WID = math.random(1,#self.PosterPoses.WPoses)
  47.     local WPos = self.PosterPoses.WPoses[WID]
  48.  
  49.     if table.HasValue(self.PosterPoses.Taken[UpOrDown], WID) then
  50.         //All poses taken, randomize location even if poster there
  51.         if #self.PosterPoses.Taken[1] + #self.PosterPoses.Taken[2] >= 20 then
  52.             return WPos, math.random(-22,22)
  53.         else
  54.             return self:GenerateID(Poster)
  55.         end
  56.     end
  57.     table.insert(self.PosterPoses.Taken[UpOrDown], WID)
  58.     Poster.IDs = {UpOrDown,WID}
  59.  
  60.     if UpOrDown == 1 then
  61.         return WPos, math.random(10,28)
  62.     elseif UpOrDown == 2 then
  63.         return WPos, math.random(-10,-32)
  64.     end
  65. end
  66.  
  67. function ENT:AddBounty(Player, Nick, Bounty, PlacedBy)
  68.     local Poster = ents.Create("bountyposter")
  69.     local IDPosF, IDPosU = self:GenerateID(Poster)
  70.    
  71.     Poster:SetMoveType(MOVETYPE_NONE)
  72.     Poster:SetParent(self)
  73.     local Ang = self:GetAngles()
  74.     Ang:RotateAroundAxis( Ang:Up(), 0 )
  75.     Poster:SetAngles(Ang)
  76.     Poster:SetPos(self:GetPos()+self:GetRight()*(IDPosF-5.25)+self:GetForward()*1+self:GetUp()*IDPosU)
  77.     Poster.Player = Player 
  78.     Poster:Spawn()
  79.     Poster.Bounty = Bounty
  80.     Poster.Board = self
  81.     if PlacedBy then
  82.         Poster.PlacedBy = PlacedBy
  83.     end
  84.    
  85.     self.Posters[Player:UniqueID()] = Poster
  86.    
  87.     //Let entity be created
  88.     timer.Simple(.1, function()
  89.         net.Start("AddNewBountyPoster")
  90.             net.WriteEntity(Poster)
  91.             net.WriteString(Nick)
  92.             net.WriteFloat(Bounty)
  93.         net.Broadcast()
  94.     end)
  95.    
  96. end
  97.  
  98. function ENT:Use(activator, caller)
  99.     if self.Entity.Touched and self.Entity.Touched > CurTime() then return ; end
  100.     self.Entity.Touched = CurTime() + .5;
  101.    
  102.     if !TBFY_BHConfig.DisableManualBounty and activator:CanPlaceBounty() then
  103.         net.Start("open_place_bounty_menu")
  104.         net.Send(activator)
  105.     end
  106. end
  107.  
  108. function ENT:Think()
  109. end
  110.  
  111. function ENT:Touch(TouchEnt)
  112.     if self.Entity.Touched and self.Entity.Touched > CurTime() then return ; end
  113.     self.Entity.Touched = CurTime() + 1;
  114. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement