Give money to medic after healing

**Hey! I have a issue with this. I found the addon for cool medkit and now i want to create after healing giving money to medic.
Code:
**
function SWEP:PrimaryAttack()
if self.Weapon:GetNWInt( “WeaponCharge”) <= 0 then
return
end
self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)

local tr = self.Owner:GetEyeTrace()
local health = tr.Entity:Health()

if not tr.Entity or not tr.Entity:IsPlayer() then return false end
if health &gt;= 100 then return false end

tr.Entity:SetHealth( tr.Entity:Health() + 1 )
self.Weapon:SetNWInt( "WeaponCharge", self.Weapon:GetNWInt( "WeaponCharge") - math.Rand(0,1) )
self:EmitSound( "hl1/fvox/boop.wav", 150, tr.Entity:Health() / tr.Entity:GetMaxHealth() * 100, 1, CHAN_AUTO )

end

**I tried paste the ** if tr.Entity:Health() >= 100 then
function DarkRP.AddMoney(1000) **but it’s didn’t worked… I know that need something but i can’t find this. I hope u’ll help me!

P.S. Sorry for my english. c:**

tr.Entity:setDarkRPVar(“money”, tr.Entity:getDarkRPVar(“money”) + 1000)

Where to paste this?

This code wouldn’t work as it would give the money to the trace.Entity which would be the player receiving health.

To answer your question, get the SWEP’s owner, after he healed the player in front of him use the DarkRP addmoney function.

This is a bad idea. Medics can get a friend to keep hurting themselves to generate free money.

Oops I wrote that without thinking.

[editline]26th February 2017[/editline]

Just for future reference use self.Owner

Sure! But now i have the another idea. Giving money for resurrection using defibrillator! I need help against

Cant you google gmod defibrillator and see how its suppose to be written?


function DefDoDeath(ply)
	local ragdoll = ents.Create("prop_ragdoll")
	ragdoll:SetPos(ply:GetPos())
	ragdoll:SetModel(ply:GetModel())
	ragdoll:Spawn()
	ply.DWeapons = {}
	for i,v in pairs(ply:GetWeapons()) do
		table.insert(ply.DWeapons,v:GetClass())
	end
	ply.DRagdoll = ragdoll
	ragdoll.Owner = ply
	ragdoll.DieTime = CurTime()
	ragdoll.RespawnCounter = 0
	ragdoll:GetPhysicsObject():SetVelocity(ply:GetPhysicsObject():GetVelocity())
	timer.Simple(0.01, function()
		if(ply:GetRagdollEntity() != nil and	ply:GetRagdollEntity():IsValid()) then
			ply:GetRagdollEntity():Remove()
		end
	end )
	

end
hook.Add( "DoPlayerDeath", "PlayerDoDeath", DefDoDeath )



function DefPlySpawn(ply)
	if(ply.DRagdoll != nil and ply.DRagdoll:IsValid()) then
		ply.DRagdoll:Remove()
		ply.DRagdoll = nil
	end
end
hook.Add( "PlayerSpawn", "DefPlySpawn", DefPlySpawn )

function DefDisconnect(ply)
	if(ply.DRagdoll != nil and ply.DRagdoll:IsValid()) then
		ply.DRagdoll:Remove()
	end
end
hook.Add( "PlayerDisconnected", "DefDisconnect", DefDisconnect )