• Ent killer
    2 replies, posted
Hi, i'm making some lua coding where I spawned an entity with some health, now I made a code where whenever he got any dmg he would lose 10 hp. The only thing I need now is some way to check wich player killed/Broke the prop... Anyone here who can help me out? Here is the code for the damage: [code] function GM:EntityTakeDamage( ent ) if not ent:IsPlayer( ) then local hp = ent:Health( ) local play = ent:GetPhysicsAttacker() PrintMessage(play .. " & " .. play:Nick()) ent:SetHealth(hp - 10) if(ent:Health( ) <= 0) then if ply:IsPlayer( ) then PrintMessage("ent physics attacker: ".. ply:Nick() .."\n") end end end end [/code]
Read:[URL="http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html"]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexedfa.html[/URL] Use the format: [CODE]GM:EntityTakeDamage( Entity Target, Entity Inflictor(usually a weapon), Entity Attacker, Number amount of damage done, Ctakedamageinfo Damage Info )[/CODE] :D
[QUOTE=bpgilly;36710664]Hi, i'm making some lua coding where I spawned an entity with some health, now I made a code where whenever he got any dmg he would lose 10 hp. The only thing I need now is some way to check wich player killed/Broke the prop... Anyone here who can help me out? Here is the code for the damage: [code] function GM:EntityTakeDamage( ent ) if not ent:IsPlayer( ) then local hp = ent:Health( ) local play = ent:GetPhysicsAttacker() PrintMessage(play .. " & " .. play:Nick()) ent:SetHealth(hp - 10) if(ent:Health( ) <= 0) then if ply:IsPlayer( ) then PrintMessage("ent physics attacker: ".. ply:Nick() .."\n") end end end end [/code][/QUOTE] You have to include all arguments in the functions attributes. Like so, [lua] function GM:EntityTakeDamage( ent, wep, attacker, damageDone, damageInfo ) ent:SetHealth( hp - 10 ); end [/lua]
Sorry, you need to Log In to post a reply to this thread.