if SERVER then
AddCSLuaFile( "shared.lua" )
resource.AddFile("models/weapons/v_defilibrator.mdl")
resource.AddFile("models/weapons/v_defilibrator.dx90.vtx")
resource.AddFile("models/weapons/v_defilibrator.dv80.vtx")
resource.AddFile("models/weapons/v_defilibrator.vtx")
resource.AddFile("models/weapons/v_defilibrator..sw.vtx")
resource.AddFile("models/weapons/v_defilibrator.vvd")
resource.AddFile("materials/models/weapons/v_defilibrator/Paddle.vmt")
resource.AddFile("materials/models/weapons/v_defilibrator/v_hand_sheet.vmt")
resource.AddFile("materials/models/weapons/v_defilibrator/v_hand_sheet_normal.vmt")
resource.AddFile("materials/vgui/ttt/icon_sourcetribe_defib.vmt")
resource.AddFile("sound/ttt/ael.wav")
resource.AddFile("sound/ttt/leeroy_boom.wav")
resource.AddFile("sound/ttt/DefendThisPosition.wav")
end
if CLIENT then
SWEP.PrintName = "Defibrillator"
SWEP.Slot = 6
SWEP.ViewModelFOV = 10
SWEP.EquipMenuData = {
type = "item_weapon",
desc =
[[Revives you allies.]]
};
SWEP.Icon = "vgui/ttt/icon_AM_defib"
end
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.ViewModel = "models/weapons/v_defilibrator.mdl"
--SWEP.WorldModel = ""
SWEP.ShowViewModel = true
SWEP.ShowWorldModel = false
--[[SWEP.VElements = {
["microwave"] = { type = "Model", model = "models/props/cs_office/microwave.mdl", bone = "ValveBiped.Bip01", pos = Vector(11.019, -21.619, 15.625), angle = Angle(-3.57, 8.512, -90.644), size = Vector(0.4, 0.4, 0.4), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}--]]
SWEP.Base = "weapon_tttbase"
SWEP.DrawCrosshair = false
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Primary.Delay = 1.0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Delay = 1.0
SWEP.Kind = WEAPON_EQUIP
SWEP.CanBuy = {ROLE_DETECTIVE}
SWEP.LimitedStock = true
SWEP.WeaponID = AMMO_DEFIB
SWEP.AllowDrop = false
SWEP.NoSights = true
if CLIENT then
function SWEP:GetViewModelPosition ( Pos, Ang )
Pos = Pos + Ang:Up() * 6
return Pos, Ang
end
end
function SWEP:Initialize()
self:SetWeaponHoldType("normal")
end
if SERVER then
function SWEP:PrimaryAttack()
local EyeTrace = self.Owner:GetEyeTrace()
local Distance = self.Owner:EyePos():Distance(EyeTrace.HitPos)
if Distance > 75 then return false end
if ValidEntity(EyeTrace.Entity) and EyeTrace.Entity:GetClass() == "prop_ragdoll" then
local ply = CORPSE.GetPlayer(EyeTrace.Entity, false)
if ply then
if ply:GetRole() == ROLE_TRAITOR then self.Owner:PrintMessage(HUD_PRINTTALK, "ERROR: This is not an innocent!") return end
local time = 25
if ( ply:GetNWString("DonorStatus", Guest)== "Bronze") then time = 40
elseif ( ply:GetNWString("DonorStatus", Guest)== "Silver") then time = 75
elseif ( ply:GetNWString("DonorStatus", Guest)== "Gold") then time = 150
elseif ( ply:GetNWString("DonorStatus", Guest)== "Diamond") then time = 250
elseif ( ply:GetNWString("DonorStatus", Guest)== "Platinum") then time = 500
elseif ( ply:GetNWString("DonorStatus", Guest)== "CoOwner") then time = 1000
elseif ( ply:GetNWString("DonorStatus", Guest)== "Founder") then time = 1000000
end
if (tonumber(ply.DiedTime) + time) < CurTime() then self.Owner:PrintMessage(HUD_PRINTTALK, "ERROR: Player has been dead for more than "..time.." seconds!") return end
local ent = EyeTrace.Entity
local player = self.Owner
self.Owner:Freeze(true)
self.Owner:EmitSound("AM/DefendThisPosition.wav", 150, 100)
timer.Simple(4, function() if player:Alive() then self.Owner:EmitSound("AM/ael.wav", 150, 100) end end)
timer.Simple(5, function()
if player:Alive() then
self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Owner:Freeze(false)
self.Owner:EmitSound("AM/leeroy_boom.wav", 100, 100)
ply:SpawnForRound(true)
ply:SetPos(ent:GetPos())
ply.ShouldntCollide = true
timer.Simple(5, function() ply.ShouldntCollide = false end)
ent:Remove()
self:Remove()
end
end)
else
self.Owner:PrintMessage(HUD_PRINTTALK, "ERROR: Unable to retrieve player/ player is not an innocent.")
end
else
self.Owner:PrintMessage(HUD_PRINTTALK, "ERROR: This is not a corpse!")
end
end
end
hook.Add("ShouldCollide", "PlayerDefib", function(ent1, ent2)
if ent1:IsPlayer() and ent2:IsPlayer() then
if ent1.ShouldntCollide then
return false
elseif ent2.ShouldntCollide then
return false
end
end
end)
function SWEP:SecondaryAttack()
return false
end
function SWEP:Reload()
return false
end
Ignore the stupid sounds, I just added them as temps. It doesnt work however. It just doesnt revive.
I would like to end up making there be a 10% chance of the revived turning traitor.... but that is way over my head!