Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------Allgemeine SWEP Informationen---------------
- SWEP.Contact = ""
- SWEP.Purpose = "Plug"
- SWEP.Instructions = "Basis SWEP!"
- SWEP.Spawnable = true
- SWEP.AdminSpawnable = true
- if SERVER then
- AddCSLuaFile("cl_init.lua")
- AddCSLuaFile("shared.lua")
- SWEP.HoldType = "pistol"
- end
- if CLIENT then
- SWEP.PrintName = "plug_gun"
- SWEP.Author = "Neutron"
- SWEP.Slot = 2
- SWEP.SlotPos = 1
- SWEP.ViewModelFOV = 70
- end
- -------------------------------------------------------------------
- ------------Models---------------------------
- SWEP.ViewModel = "models/weapons/v_pistol.mdl"
- SWEP.WorldModel = "models/weapons/w_pistol.mdl"
- ----------------------------------------------
- -------------Primäre SWEP Eigenschaften ( Linke Maustaste )------------------
- SWEP.Primary.Delay = 0
- SWEP.Primary.Recoil = 0
- SWEP.Primary.Damage = 0
- SWEP.Primary.NumShots = 0
- SWEP.Primary.Cone = 0
- SWEP.Primary.ClipSize = -1
- SWEP.Primary.DefaultClip = -1
- SWEP.Primary.Automatic = false
- SWEP.Primary.Ammo = "none"
- -----------------------------------------------------------------------------
- -------------Sekundäre SWEP Eigenschaften ( Rechte Maustaste )---------------
- SWEP.Secondary.Delay = 0
- SWEP.Secondary.Recoil = 0
- SWEP.Secondary.Damage = 0
- SWEP.Secondary.NumShots = 0
- SWEP.Secondary.Cone = 0
- SWEP.Secondary.ClipSize = -1
- SWEP.Secondary.DefaultClip = -1
- SWEP.Secondary.Automatic = false
- SWEP.Secondary.Ammo = "none"
- -----------------------Hauptfunktionen----------------------------
- SWEP.Creating = false
- SWEP.Ghost = NULL
- function SWEP:Think()
- if CLIENT then
- if self.Owner ~= LocalPlayer() then return end
- if not self.Ghost:IsValid( ) then
- self.Ghost = ents.Create("prop_physics")
- self.Ghost:SetModel("models/props_lab/tpplugholder_single.mdl")
- self.Ghost:SetOwner(self.Owner)
- end
- local tr = {}
- tr.start = self.Owner:GetShootPos()
- tr.endpos = self.Owner:GetShootPos() + 200 * self.Owner:GetAimVector()
- tr.filter = {self.Ghost, self.Owner}
- local trace = util.TraceLine(tr)
- if not self.Ghost:IsValid() then return end
- local center = self.Ghost:LocalToWorld(self.Ghost:OBBCenter() + Vector(0,1,.6))
- local pos = self.Ghost:GetPos()
- local offset = center - pos
- local PlugPos = trace.HitPos - offset
- RunConsoleCommand("SetPos", PlugPos)
- if trace.HitWorld then
- self.Ghost:SetPos(PlugPos)
- self.Ghost:SetAngles(trace.HitNormal:Angle())
- self.Ghost:SetColor(255, 255, 255, 100)
- else
- self.Ghost:SetColor(255, 255, 255, 0)
- end
- if LocalPlayer():GetActiveWeapon():GetClass() != "plug_gun" then
- self.Ghost:SetColor(0,0,0,0)
- end
- end
- end
- function SWEP:PrimaryAttack()
- if self.Creating then return end
- local trace = self.Owner:GetEyeTrace()
- local Start = CurTime()
- self.Owner:SetNWInt("Start", Start)
- self.Creating = true
- self.Owner:SetNWBool("Allow", true)
- if not trace.Hit then return end
- timer.Create("SpawnTimer", 15, 1, function() self:Create() end)
- end
- function SWEP:SecondaryAttack()
- return
- end
- function SWEP:Create()
- local tr = {}
- tr.start = self.Owner:GetShootPos()
- tr.endpos = self.Owner:GetShootPos() + 200 * self.Owner:GetAimVector()
- tr.filter = {self.Ghost, self.Owner}
- local trace = util.TraceLine(tr)
- concommand.Add("SetPos", function(ply, cmd, args)
- --if !ValidEntity(ply) then return end
- --if !args[1] then return end
- Position = args[1]
- print(Position)
- end)
- self.Plug = ents.Create("plug")
- self.Plug:SetOwner(self.Owner)
- self.Plug:SetAngles(trace.HitNormal:Angle())
- self.Plug:SetColor(255,255,255,255)
- self.Plug:SetPos(Position)
- self.Plug:Spawn()
- self.Creating = false
- self.Owner:SetNWBool("Allow", false)
- end
- function SWEP:Fail()
- self.Creating = false
- self.Owner:SetNWBool("Allow", false)
- timer.Destroy("SpawnTimer")
- end
- function SWEP:DrawHUD()
- if self.Owner:GetNWBool("Allow") == true then
- local time = 15
- local curtime = CurTime() - self.Owner:GetNWInt("Start")
- local status = curtime/time
- local CreatingProgress = status * (ScrW() * 0.3)
- local Progress = math.Clamp(CreatingProgress, 0, ScrW()*0.3)
- draw.RoundedBox(2, (ScrW() / 2) - ((ScrW()*0.3)/2), (ScrH() / 2) - 15, Progress, 30, Color(255-(status * 255), status * 255, 0, 255))
- surface.SetDrawColor(100,100,100,255)
- surface.DrawOutlinedRect((ScrW() / 2) - ((ScrW()*0.3)/2), (ScrH() / 2 - 16), ScrW()*0.3, 32)
- end
- end
Add Comment
Please, Sign In to add comment