Hello everybody of facepunch. I am asking a relatively simple question, that unexperienced people like me would not know. How would I make the darkrp medkit, heal each job to their maximum health. Thanks :D
In the medkit, I'm sure it has some statement like "if Player:Health < 100 then" or "math.Clamp( amount, 100 )"
Whatever that statement is, change the 100 in the medkit to Player:GetMaxHealth().
Ok there is stuff sort of like that but there I multiple it looks like this
function SWEP:PrimaryAttack()
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
local found
local lastDot = -1 -- the opposite of what you're looking at
self:GetOwner():LagCompensation(true)
local aimVec = self:GetOwner():GetAimVector()
for k,v in pairs(player.GetAll()) do
local maxhealth = v:GetMaxHealth() or 100
if v == self:GetOwner() or v:GetShootPos():Distance(self:GetOwner():GetShootPos()) > 85 or v:Health() >= maxhealth or not v:Alive() then continue end
local direction = v:GetShootPos() - self:GetOwner():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
self:GetOwner():LagCompensation(false)
if found then
found:SetHealth(found:Health() + 1)
self:EmitSound("hl1/fvox/boop.wav", 150, found:Health() / found:GetMaxHealth() * 100, 1, CHAN_AUTO)
end
end
function SWEP:SecondaryAttack()
self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay)
local ply = self:GetOwner()
local maxhealth = self:GetOwner():GetMaxHealth() or 100
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 1)
self:EmitSound("hl1/fvox/boop.wav", 150, ply:Health() / ply:GetMaxHealth() * 100, 1, CHAN_AUTO)
end
end
Where exactly do I place this line of code. Thanks for helping
The code looks like it already does. Are you setting the max health of the job correctly?
PlayerLoadout = function(ply)
ply:SetHealth(999999999)
ply:SetArmor(999)
end,
This is what my health command looks like
You're not setting the MaxHealth.
Ahh my bad is there a proper way of doing this?
Or MaxArmor for that matter.
[editline]5th June 2016[/editline]
[QUOTE=shucksnoris;50461243]Ahh my bad is there a proper way of doing this?[/QUOTE]
SetMaxHealth, SetMaxArmor
Wait so would I just replace the SetHealth and SetArmor with what you just typed. Sorry if I sound like an idiot I really am.
[QUOTE=shucksnoris;50461269]Wait so would I just replace the SetHealth and SetArmor with what you just typed. Sorry if I sound like an idiot I really am.[/QUOTE]
No, just run SetMaxHealth and SetMaxArmor as well. Also, I would not make the values that large, as the medkit would heal them for essentially infinite time.
Ahh thanks for the tip man that pretty much cleared it up.
One more thing though. You said it would a really long time right? Well is there a way of healing a fraction of there max health at a time?
Sorry, you need to Log In to post a reply to this thread.