Ребят, ломаю голову, не могу правильно прописать функцию. Я пытаюсь сделать в рации так, чтобы при перезарядки на определённой частоте(ну скажем 92.2) активировался код, однако код активируется на любой частоте, как правильно прописать и что именно нужно? Вот код
function SWEP:Initialize() self.OnlyOneBackup = false self:SetWeaponHoldType( "magic" ) self:SetHoldType("normal") self.DownAmt=20 self:SetActive(false) self:Setabab(false) self:SetEarpiece(self.HasEarpiece or false) self:SetChannel(1) self:SCKInitialize() if(SERVER)then self:PhysicsInitBox(Vector(-5,-5,-5),Vector(5,5,5)) self:SetCollisionBounds(Vector(-5,-5,-5),Vector(5,5,5)) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS) local Phys=self:GetPhysicsObject() Phys:Wake() Phys:SetMass(10) end end function SWEP:SetupDataTables() self:NetworkVar("Bool",0,"Active") self:NetworkVar("Bool",1,"Earpiece") self:NetworkVar("Int",0,"Channel") self:NetworkVar("Bool",0,"abab") end function SWEP:PrimaryAttack() self:SetActive(!self:GetActive()) self:EmitSound("snd_jack_job_radioswitch.wav",60,110) if(self:GetActive())then self.VElements.light.color.a=255 else self.VElements.light.color.a=0 end self:SetNextPrimaryFire(CurTime()+.5) end function SWEP:Deploy() self:SetNextPrimaryFire(CurTime()+1) self.DownAmt=20 return true end function SWEP:Holster() self:SCKHolster() return true end -- this is messy, don't care. Ain't paid enough to be doing derma menus honestly if(SERVER)then util.AddNetworkString("jackjob_drp_radiochannelmenu") end function SWEP:SecondaryAttack() if not(self:GetActive())then return end if(SERVER)then net.Start("jackjob_drp_radiochannelmenu") net.WriteEntity(self) net.Send(self.Owner) end --[[ local NewChannel=self:GetChannel()+1 if(NewChannel>100)then NewChannel=1 end self:SetChannel(NewChannel) self:EmitSound("snd_jack_job_radioswitch.wav",40,90) --]] self:SetNextSecondaryFire(CurTime()+.1) end if(CLIENT)then net.Receive("jackjob_drp_radiochannelmenu",function(len,ply) local Wep=net.ReadEntity() local DermaPanel=vgui.Create("DFrame") DermaPanel:SetPos(40,80) DermaPanel:SetSize(500,100) DermaPanel:SetTitle("Select Channel") DermaPanel:SetVisible(true) DermaPanel:SetDraggable(true) DermaPanel:ShowCloseButton(true) DermaPanel:MakePopup() DermaPanel:Center() local DermaNumSlider=vgui.Create("DNumSlider",DermaPanel) DermaNumSlider:SetPos(10,25) DermaNumSlider:SetSize(490,50) DermaNumSlider:SetText("Channel") DermaNumSlider:SetMin(80.1) DermaNumSlider:SetMax(130.1) DermaNumSlider:SetDecimals(1) DermaNumSlider:SetValue(Wep:GetChannel()/10+90) DermaNumSlider.OnValueChanged=function(panel,val) RunConsoleCommand("jackjob_drpradio_setchannel",tostring(math.Round(val ,1))) end end) end if(SERVER)then concommand.Add("jackjob_drpradio_setchannel",function(ply,txt,args) if(ply:HasWeapon("wep_jack_job_drpradio"))then local self=ply:GetWeapon("wep_jack_job_drpradio") if(self:GetActive())then local Chan=tonumber(args[1])
if((Chan>=80.1)and(Chan<=130.1))then self:EmitSound("snd_jack_job_radioswitch.wav",30,90) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100)) elseif((Chan>=95.7)and(Chan<=95.7))then self:EmitSound("radio_voice_1.wav",45,100) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100))
elseif((Chan>=97.5)and(Chan<=97.5))then self:EmitSound("radio_voice_2.wav",45,100) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100))
elseif((Chan>=91.2)and(Chan<=91.2))then self:EmitSound("radio_voice_3.wav",45,100) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100))
elseif((Chan>=99.9)and(Chan<=99.9))then self:EmitSound("radio_voice_4.wav",45,100) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100))
elseif((Chan>=100.1)and(Chan<=100.1))then self:EmitSound("radio_voice_5.wav",45,100) local Rounded=math.Round((Chan-90)*10) self:SetChannel(math.Clamp(Rounded,1,100)) end ВОТ НУЖНАЯ ЧАСТОТА if(Chan==92.2)then self:EmitSound("radio_voice_1.wav",45,100) end end end end) end function SWEP:Think() -- end function SWEP:CallBackup(tr)
if SERVER then local tr = self.Owner:GetEyeTrace() if tr.HitPos:Distance(self:GetPos()) > 200 or ( IsValid( self.ent1 ) or IsValid( self.ent2 ) or IsValid( self.ent3 ) ) then self:EmitSound("Engi.Block") else self.ent1 = ents.Create( "elite_backup" ) self.ent2 = ents.Create( "elite_backup" ) self.ent3 = ents.Create( "elite_backup" ) self.ent1:SetPos(Vector(self.Owner:GetEyeTrace().HitPos.x, self.Owner:GetEyeTrace().HitPos.y, self.Owner:GetPos().z)) self.ent2:SetPos(Vector(self.ent1:GetPos().x-45, self.ent1:GetPos().y-45, self.ent1:GetPos().z)) self.ent3:SetPos(Vector(self.ent1:GetPos().x+45, self.ent1:GetPos().y-45, self.ent1:GetPos().z)) local newAng = Angle(0, self.Owner:GetAngles().y, 0) self.ent1:SetAngles( newAng ) self.ent2:SetAngles( newAng ) self.ent3:SetAngles( newAng ) self.ent1:SetOwner( self.Owner ) self.ent2:SetOwner( self.Owner ) self.ent3:SetOwner( self.Owner ) timer.Simple(2, function() if self.Owner:Alive() then self.ent1:Spawn() self.ent1:Activate() self.ent2:Spawn() self.ent2:Activate() self.ent3:Spawn() self.ent3:Activate() end end) self:EmitSound( Request[math.random(1,2)], 100, 100 )
cleanup.Add( self.Owner, "props", self.ent1 ) cleanup.Add( self.Owner, "props", self.ent2 ) cleanup.Add( self.Owner, "props", self.ent3 ) end end end function SWEP:Reload() ВОТ САМ КОД self.Owner:SetAnimation(PLAYER_ATTACK1) self:CallBackup() self.Weapon:SetNextPrimaryFire( CurTime() + 1.00 ) ------------------ if IsValid(self.ent1) and self.Owner:KeyDown(IN_ATTACK2) then self:KillMe(self.ent1) end if IsValid(self.ent2) and self.Owner:KeyDown(IN_ATTACK2) then self:KillMe(self.ent2) end if IsValid(self.ent3) and self.Owner:KeyDown(IN_ATTACK2) then self:KillMe(self.ent3) end end?