So I’m trying to make a script that gives the player money when he breaks a func_breakable, is this possible to do? I already have the giving money part figured out, just trying to figure out how to check what player broke the func_breakable when its broken.
Maybe use the GM:EntityTakeDamage hook
Thanks! I got it to work. Althought I have another problem, it gives me 1 dollar for every hit, I want it to only give me money if it breaks.
function GM:EntityTakeDamage( target, dmginfo ) if ( target:IsSolid() ) then dmginfo:GetAttacker():money_give(1) else return end end
First, isn’t that going to give money to anyone who damages any solid entity? Second, I think it’d be safe to check if the attacker is an actual player as well.
Also, it shouldn’t be “when take damage -> give attacker money” but instead “if damage will destroy this entity -> give attacker money”.
In the gamemode im making there maps func_breakable are the only solid entities, also how do I make it so if damage destroys the entity it gives money?
The easiest way to do it would be along the lines of:
[lua]hook.Add(“EntityTakeDamage”, “aaaa”, function(ent, dmg)
if not ent:IsSolid() then return end
local ply = dmg:GetAttacker()
if not IsValid(ply) then return end
if not ply:IsPlayer() then return end
if not ent:IsValid() then