I am new at this scripting stuff i only know the basics. But i am having an issue with making the medkits heal past 100 to heal someone with 200, 500, and 7000 health. And when someone pulls out the default batons (arrest, unarrest, and stun stick) they start to walk till they kill their self. please help?
I think the limit has been set to 100. Try to set it to ply:GetMaxHealth()
I tried that but it did not work. I changed all the maxhealth first then restarted tried it still didnt work so then i changed all of them that says max health and still didnt.
if you mean the default medkit from gmod then look @ line 65
[code]
ent:SetHealth( math.min( ent:GetMaxHealth(), ent:Health() + need ) )
[/code]
My line 65 is empty and nothing on there shows that line anything else? I'm also new to this so how would i be able to show you the file???
Is the medikit the default HL2 medikit, or from scriptfodder? Aslong as its not an paid addon you simply can copy the code, and paste it here between CODE tags.
I am trying to change the HL2 one so it heals past 100 but idk how. I tried to mess with it but nothing works.
then line 65 shouldn't be empty..
Its as empty as my essays in high school. Do i need to add this in line 65???
[QUOTE='[HG]Sah Marzu;49302661']Its as empty as my essays in high school. Do i need to add this in line 65???[/QUOTE]
Press CTRL + F and see if you can it.
just paste the whole code here in CODE tags.
[CODE]if SERVER then
AddCSLuaFile("shared.lua")
end
SWEP.PrintName = "Medic Kit"
SWEP.Author = "DarkRP Developers"
SWEP.Slot = 4
SWEP.SlotPos = 0
SWEP.Description = "Heals the wounded."
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = "Left click to heal someone\nRight click to heal yourself"
SWEP.Spawnable = true
SWEP.AdminOnly = 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.01
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Recoil = 0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Delay = 0.03
SWEP.Secondary.Ammo = "none"
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 7000
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() + 7)
self:EmitSound("hl1/fvox/boop.wav", 150, found:Health() / found:GetMaxHealth() * 7000, 1, CHAN_AUTO)
end
end
function SWEP:SecondaryAttack()
self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay)
local ply = self:GetOwner()
local maxhealth = self:GetOwner():GetMaxHealth() or 7000
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 10)
self:EmitSound("hl1/fvox/boop.wav", 150, ply:Health() / ply:GetMaxHealth() * 7000, 1, CHAN_AUTO)
end
end
[/CODE]
[editline]13th December 2015[/editline]
Wow i'm bad at this XD anyways thats my coding for the med kit sorry i couldnt do it correctly i just started this like 2days ago.
[QUOTE='[HG]Sah Marzu;49306661'][CODE][/CODE]if SERVER then
AddCSLuaFile("shared.lua")
end
SWEP.PrintName = "Medic Kit"
SWEP.Author = "DarkRP Developers"
SWEP.Slot = 4
SWEP.SlotPos = 0
SWEP.Description = "Heals the wounded."
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = "Left click to heal someone\nRight click to heal yourself"
SWEP.Spawnable = true
SWEP.AdminOnly = 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.01
SWEP.Primary.Ammo = "none"
SWEP.Secondary.Recoil = 0
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 1
SWEP.Secondary.Automatic = true
SWEP.Secondary.Delay = 0.03
SWEP.Secondary.Ammo = "none"
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(7000) or 7000
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() + 7)
self:EmitSound("hl1/fvox/boop.wav", 150, found:Health() / found:GetMaxHealth() * 7000, 1, CHAN_AUTO)
end
end
function SWEP:SecondaryAttack()
self:SetNextSecondaryFire(CurTime() + self.Secondary.Delay)
local ply = self:GetOwner()
local maxhealth = self:GetOwner():GetMaxHealth(7000) or 7000
if ply:Health() < maxhealth then
ply:SetHealth(ply:Health() + 10)
self:EmitSound("hl1/fvox/boop.wav", 150, ply:Health() / ply:GetMaxHealth() * 7000, 1, CHAN_AUTO)
end
end
[CODE][/CODE]
[editline]13th December 2015[/editline]
Wow i'm bad at this XD anyways thats my coding for the med kit sorry i couldnt do it correctly i just started this like 2days ago.[/QUOTE]
Wrap the code in [lua] tags please
click on the 'edit' button below your post and put code /code in [] around it.
Remove the "v:GetMaxHealth(7000)"
There we go i fixed it thank you sorry to frustatrate you on that one.
sorry i looked into it more i was messing with the darkrp default one im sorry.
[editline]14th December 2015[/editline]
where would i like the HL2 medkit in the files anyways???
"garrysmod/lua/weapons/weapon_medkit.lua"
mk i found it but now what do i change? i did the line 65 but it didnt work? is there more to it?
I know this is a really old post but i wish to get medkits to work on my server i am kinda new at this. I put in the code from Sah Marzu into my medkit.lua in the garrys mod lua. It did not work then i deleted the code and now the medkit will not show up at all. If any one has suggestions it would be greatly appreciated
Sorry, you need to Log In to post a reply to this thread.