• GM:PlayerHurt problem
    6 replies, posted
I am pretty sure I am doing everything right: [CODE]function GM:PlayerHurt( ply, victim, attacker, damageTaken ) local health = victim:Health() if damageTaken > 20 then ply:ChatPrint( "You might be hurting..." ) end end[/CODE] Any ideas? EDIT: I forgot to tell you the problem, I don't think [CODE]if damageTaken > 20 then[/CODE]is working properly because it's not printing to the chat and it seems it would.
-snip-
Print damagetaken value to console and see what it equals to?
[QUOTE=Robotboy655;44458556]Print damagetaken value to console and see what it equals to?[/QUOTE] Nothing. At all.
-snip again -,- -
you had arguments wrong, and you should probably use a hook unless you're modifying a gamemode [LUA] local function PlayerHurt( victim, attacker, health, dmg ) local att = attacker:IsPlayer() and attacker:Nick() or "the guardians" if health > 20 then victim:ChatPrint( "Your health is under 20" ) end victim:ChatPrint( "You got hurt for " .. dmg .. " by " .. att ) end hook.Add( "PlayerHurt", "LowHealth", PlayerHurt ) [/LUA] [url]http://wiki.garrysmod.com/page/GM/PlayerHurt[/url]
Looks like that will work, I wish this function just used dmginfo. It's a gamemode. Thanks for the double answer guys.
Sorry, you need to Log In to post a reply to this thread.