• Freezing lua question
    1 replies, posted
So I believe there is two ways to freeze player and it is lock and freeze, But lock doesn't seem to work and freeze only worked on a bot Im doing this with a darkrp bnaton that was modified. The code: [CODE]function SWEP:PrimaryAttack() if CurTime() < self.NextStrike then return end self:SetHoldType("melee") timer.Simple(0.3, function() if self:IsValid() then self:SetHoldType("normal") end end) self.NextStrike = CurTime() + 0.51 -- Actual delay is set later if CLIENT then return end timer.Stop(self:GetClass() .. "_idle" .. self:EntIndex()) local vm = self.Owner:GetViewModel() if IsValid(vm) then vm:ResetSequence(vm:LookupSequence("idle01")) timer.Simple(0, function() if not IsValid(self) or not IsValid(self.Owner) or not IsValid(self.Owner:GetActiveWeapon()) or self.Owner:GetActiveWeapon() ~= self then return end self.Owner:SetAnimation(PLAYER_ATTACK1) if IsValid(self.Weapon) then self.Weapon:EmitSound(self.Sound) end local vm = self.Owner:GetViewModel() if not IsValid(vm) then return end vm:ResetSequence(vm:LookupSequence("attackch")) vm:SetPlaybackRate(1 + 1/3) local duration = vm:SequenceDuration() / vm:GetPlaybackRate() timer.Create(self:GetClass() .. "_idle" .. self:EntIndex(), duration, 1, function() if not IsValid(self) or not IsValid(self.Owner) then return end local vm = self.Owner:GetViewModel() if not IsValid(vm) then return end vm:ResetSequence(vm:LookupSequence("idle01")) end) self.NextStrike = CurTime() + duration end) end self.Owner:LagCompensation(true) local trace = util.QuickTrace(self.Owner:EyePos(), self.Owner:GetAimVector() * 90, {self.Owner}) self.Owner:LagCompensation(false) if IsValid(trace.Entity) and trace.Entity.onUnArrestStickUsed then trace.Entity:onUnArrestStickUsed(self.Owner) return end local ent = self.Owner:getEyeSightHitEntity(nil, nil, function(p) return p ~= self.Owner and p:IsPlayer() and p:Alive() end) if not ent then return end if not IsValid(ent) or not ent:IsPlayer() or not ent:IsBot() or (self.Owner:EyePos():Distance(ent:GetPos()) > 115) then return end ent:Freeze(true) timer.Simple( 5, function() ent:Freeze(false)(self.Owner) end ) DarkRP.notify(ent, 0, 4, DarkRP.getPhrase("youre_frozen_by", self.Owner:Nick "for 5 Seconds"())) end[/CODE]
[QUOTE=DeadShotKillz;45920723]So I believe there is two ways to freeze player and it is lock and freeze, But lock doesn't seem to work and freeze only worked on a bot Im doing this with a darkrp bnaton that was modified.[/QUOTE] If it's working on bots and not players maybe check your if statements?
Sorry, you need to Log In to post a reply to this thread.