• Health
    8 replies, posted
Does anyone know how to change the speed of the health that the medkit gives you its very slow [lua] if (SERVER) then AddCSLuaFile("shared.lua") end SWEP.PrintName = "Medic Kit" SWEP.Author = "DarkRP Developers" SWEP.Slot = 3 SWEP.SlotPos = 0 SWEP.Description = "Heals the wounded." SWEP.Contact = "" SWEP.Purpose = "" SWEP.Instructions = "Left Click to heal player infront of user." SWEP.Spawnable = false -- Change to false to make Admin only. SWEP.AdminSpawnable = true SWEP.Category = "DarkRP (Utility)" SWEP.ViewModel = "models/weapons/c_medkit.mdl" SWEP.WorldModel = "models/weapons/w_medkit.mdl" SWEP.UseHands = true SWEP.Primary.Recoil = 0 SWEP.Primary.ClipSize = -1 SWEP.Primary.DefaultClip = 1 SWEP.Primary.Automatic = true SWEP.Primary.Delay = 0.1 SWEP.Primary.Ammo = "none" SWEP.Secondary.Recoil = 0 SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = 1 SWEP.Secondary.Automatic = true SWEP.Secondary.Delay = 0.3 SWEP.Secondary.Ammo = "none" function SWEP:PrimaryAttack() self.Weapon:SetNextPrimaryFire(CurTime() + self.Primary.Delay) if not SERVER then return end local found local lastDot = -1 -- the opposite of what you're looking at local aimVec = self.Owner:GetAimVector() for k,v in pairs(player.GetAll()) do local maxhealth = v:GetMaxHealth() or 100 if v == self.Owner or v:GetShootPos():Distance(self.Owner:GetShootPos()) > 85 or v:Health() >= maxhealth or not v:Alive() then continue end local direction = v:GetShootPos() - self.Owner:GetShootPos() direction:Normalize() local dot = direction:Dot(aimVec) -- Looking more in the direction of this player if dot > lastDot then lastDot = dot found = v end end if found then found:SetHealth(found:Health() + 1) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, found:Health()) end end function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire(CurTime() + self.Secondary.Delay) if not SERVER then return end local maxhealth = self.Owner:GetMaxHealth() or 100 if self.Owner:Health() < maxhealth then self.Owner:SetHealth(self.Owner:Health() + 1) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, self.Owner:Health()) end end [/lua]
Change this line in the primary fire function: [CODE]if found then found:SetHealth(found:Health() + 1) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, found:Health()) end[/CODE] To this: [CODE]if found then if found:Health() + 3 > 100 then found:SetHealth(100) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, found:Health()) else found:SetHealth(found:Health() + 3) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, found:Health()) end end[/CODE] That will triple the speed. And for the secondary fire: [CODE]function SWEP:SecondaryAttack() self.Weapon:SetNextSecondaryFire(CurTime() + self.Secondary.Delay) if not SERVER then return end local maxhealth = self.Owner:GetMaxHealth() or 100 if self.Owner:Health() < maxhealth then if self.Owner:Health() +3 > 100 then self.Owner:SetHealth(maxhealth) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, self.Owner:Health()) else self.Owner:SetHealth(self.Owner:Health() + 3) self.Owner:EmitSound("hl1/fvox/boop.wav", 150, self.Owner:Health()) end end end[/CODE]
didnt change...
Woops, forgot to change something. Edited code, try now.
still nothing
I cannot comprehend how you are getting this wrong. This is as simple as changing two values in the code. If you cannot do something as simple as that, then the only person that can help you is a doctor.
If you update the code in real-time, you will need to despawn the weapon and respawn it in order to see some of the changes unless they are external calls. As these are internal, respawn the weapon...
Please correct me if im wrong but isn't it just [B]SWEP.Primary.Delay = 0.1[/B]?
[QUOTE=_Jacob;44305769]Please correct me if im wrong but isn't it just [B]SWEP.Primary.Delay = 0.1[/B]?[/QUOTE] Either method works. Mine changed the actual amount healed.
Sorry, you need to Log In to post a reply to this thread.