Hello, I'm trying to make it, the player being hit, slow for a few seconds, but I'm not getting it , for now my code is like this:
local HitEntity = IsValid(tr.Entity) and tr.Entity or Entity(0)
local damage = self.Primary.Damage
local force = aimvec:GetNormalized() * 300 * self.Primary.Force
local damageinfo = DamageInfo()
local old1 = ent:GetWalkSpeed()
local old2 = ent:GetRunSpeed()
local old3 = ent:GetJumpPower()
damageinfo:SetAttacker(biter)
damageinfo:SetInflictor(self)
damageinfo:SetDamage(damage)
damageinfo:SetDamageType(bit.bor(DMG_BULLET,DMG_NEVERGIB))
damageinfo:SetDamageForce(force)
damageinfo:SetDamagePosition(biteRng)
HitEntity:DispatchTraceAttack(damageinfo, tr, aimvec)
ent:SetWalkSpeed(20)
ent:SetRunSpeed(20)
ent:SetJumpPower(0)
timer.Create(tName, 5, 1, function()
if ent:IsValid()
then
ent:SetWalkSpeed(old1)
ent:SetRunSpeed(old2)
ent:SetJumpPower(old3)
end
I'm reading some famous sweep codes and trying to modify them a bit, to learn more about glua.
Okay, first thing is that you arent using the same variable to define your entity throughout as in this part
HitEntity:DispatchTraceAttack(damageinfo, tr, aimvec) your entity variable is HitEntity where as through the rest of the code you are using the variable ent. Is this the full code for the weapon? because in this section a bunch of your variables have not been defined.
I already got it repaired, but thanks for answering!
Sorry, you need to Log In to post a reply to this thread.