SWEP.ViewModelFlip 			= false
SWEP.UseHands			= true
SWEP.ViewModel 			= "models/medicmod/bandage/v_bandage.mdl"
SWEP.WorldModel 		= "models/medicmod/bandage/w_bandage.mdl"
SWEP.Author				= "Scripty"
SWEP.Instructions		= "На лкм лечить другого, на пкм сеья(спасает от переломов)"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.Primary.Damage         = 2
SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"
SWEP.Primary.Delay 		= 2

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"
SWEP.Secondary.Delay 		= 2

SWEP.Category 			= "Medic Mod"
SWEP.PrintName			= "Шина"
SWEP.Slot				= 1
SWEP.SlotPos			= 1
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= true

function SWEP:PrimaryAttack()
    self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
    local ply = self.Owner
    if not IsValid(ply) then return end

    local ent = ply:GetEyeTrace().Entity
    if not IsValid(ent) or not ent:IsPlayer() or ent:GetPos():Distance(ply:GetPos()) > 200 then
        return
    end

    if SERVER then
        local used = false

        if ent:HaveFractures() then
            for k,v in pairs(ent:GetFractures() or {}) do
                ent:SetFracture(false, k)
                used = true
            end
        end

        if ent:IsBleeding() then
            ent:SetBleeding(false)
            used = true
        end

        if used then
            self:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
            ply:SetAnimation(PLAYER_ATTACK1)
            ply:MedicNotif(ConfigurationMedicMod.Sentences["SomeoneStopBleedingOfYou"][ConfigurationMedicMod.Language], 5)
            ent:MedicNotif(ConfigurationMedicMod.Sentences["You have no more fracture"][ConfigurationMedicMod.Language], 5)
            ent:MedicNotif(ConfigurationMedicMod.Sentences["SomeoneStopBleedingOfYou"][ConfigurationMedicMod.Language], 5)
            self:Remove()
        end
    end
end

function SWEP:SecondaryAttack()
    self.Weapon:SetNextSecondaryFire(CurTime() + self.Secondary.Delay)

    local ply = self.Owner
    if not IsValid(ply) then return end

    if SERVER then
        local used = false
        if ply:HaveFractures() then
            for k,v in pairs(ply:GetFractures() or {}) do
                ply:SetFracture(false, k)
                used = true
            end
        end
        if ply:IsBleeding() then
            ply:SetBleeding(false)
            used = true
        end
        if used then
            self:SendWeaponAnim(ACT_VM_SECONDARYATTACK)
            ply:SetAnimation(PLAYER_ATTACK1)
            ply:MedicNotif(ConfigurationMedicMod.Sentences["You have no more fracture"][ConfigurationMedicMod.Language], 5)
            ply:MedicNotif(ConfigurationMedicMod.Sentences["StopBleedingOfYourself"][ConfigurationMedicMod.Language], 5)
            self:Remove()
        end
    end
end

function SWEP:Deploy()
   return true
end
function SWEP:Initialize()
    self:SetHoldType("pistol")
end

function SWEP:Holster()
    return true
end
