include('shared.lua') local HoverTex=Material("effects/blueflare1") local EnterMessageAlpha=0 LocalPlayerIsDrivingShuttle=false function ShuttleLocalDrivingChanged(entity, name, oldval, newval) if newval==true and LocalPlayerIsDrivingShuttle==false then EnterMessageAlpha=4 end LocalPlayerIsDrivingShuttle=newval end hook.Add("InitPostEntity","ShuttleInitAddProxy",function() LocalPlayer():SetNetworkedVarProxy( "isDriveShuttle", ShuttleLocalDrivingChanged ) end) ENT.ShuttleInstructions={ "You're flying a shuttle! This is a versatile, moddable air vehicle.", "LEFT MOUSE - Forwards", "RIGHT MOUSE - Backwards", "WALK FORWARD - Fast forwards", "STRAFE LEFT + RIGHT - Roll", "RUN - Look around/hover", "DUCK + JUMP - Zoom in and out" } function ShuttleDrawInfoOverlay() local shutl=LocalPlayer():GetNetworkedEntity("Shuttle",LocalPlayer()) if EnterMessageAlpha>0 and shutl~=LocalPlayer() and shutl.ShuttleInstructions then EnterMessageAlpha=EnterMessageAlpha-0.01 local tmsgA=math.Clamp(EnterMessageAlpha,0,1) for k,v in pairs(shutl.ShuttleInstructions) do local individualsize=25 local totalsize=#shutl.ShuttleInstructions*individualsize draw.WordBox(4, 50, (ScrH()/2)-(totalsize/2)+(individualsize*k), v, "Default", Color(200,150,0,128*tmsgA), Color(0,0,0,255*tmsgA) ) end end if shutl~=LocalPlayer() and LocalPlayerIsDrivingShuttle then draw.WordBox(4, 0, ScrH()-100, "Shuttle Health: "..math.Round(shutl:GetNetworkedInt("health",0)), "Default", Color(0,0,0,200), Color(255,255,255,255) ) end end hook.Add("HUDPaint","NewShuttleDrawInfoOverlay",ShuttleDrawInfoOverlay) function ENT:Draw() self.Entity:DrawModel() if not LocalPlayerIsDrivingShuttle and ( LocalPlayer():GetEyeTrace().Entity == self.Entity && EyePos():Distance( self.Entity:GetPos() ) < 512 ) then AddWorldTip(self.Entity:EntIndex(),"Health: "..tostring(self.Entity:GetNetworkedInt("health",0)),0.5,self.Entity:GetPos(),self.Entity) end if self.Entity:GetNetworkedBool("hover",false) then local size=math.abs(math.Clamp(math.sin(CurTime()*2),0,1)*300) local alph=math.abs(math.Clamp(math.sin(CurTime()),0,1)) render.SetMaterial( HoverTex ) render.DrawSprite(self.Entity:GetPos(), size, size, Color(50,50,200,alph)) end end function sCalc( ply, origin, angles, fov ) if not LocalPlayer().sDistz then LocalPlayer().sDistz=100 end if LocalPlayer().sDistz<1 then LocalPlayer().sDistz=1 end if LocalPlayer().sDistz>1000 then LocalPlayer().sDistz=1000 end local shut=LocalPlayer():GetNetworkedEntity("Shuttle",LocalPlayer()) if LocalPlayerIsDrivingShuttle and shut~=LocalPlayer() and shut:IsValid() then local view = {} view.origin = (shut:GetPos()+(shut:GetUp()*25))+ply:GetAimVector():GetNormal()*-LocalPlayer().sDistz view.angles = angles return view end end hook.Add("CalcView", "NewShuttleCalcView", sCalc) function ENT:Think() if LocalPlayerIsDrivingShuttle then if LocalPlayer():KeyDown(IN_JUMP) then LocalPlayer().sDistz=LocalPlayer().sDistz+5 end if LocalPlayer():KeyDown(IN_DUCK) then LocalPlayer().sDistz=LocalPlayer().sDistz-5 end end end