IsEnemyEntityName() returns a weird string. Not usable in a if statementf
2 replies, posted
if SERVER then
util.AddNetworkString("AttackerName")
hook.Add("PlayerShouldTakeDamage", "AttackerName", function(ply , attacker)
net.Start("AttackerName")
net.WriteEntity(attacker)
net.Send(ply)
end)
else
net.Receive("AttackerName",function()
local attacker = net.ReadEntity()
print(attacker)
file.Write("Attacker.txt", attacker)
if IsEnemyEntityName(attacker) then
chat.AddText("Neurotoxin detected")
end
end)
end
Right now i want to add a new Feature to my newest Addon, when the player gets hit by a poison headcrap the Addon runs the chat.AddText. Or whatever else i put in there.
Like the HEV suit in Half life, or even in gmod with the message "Neurotoxin detected" and giving you some health every few seconds.
Is there a easier way to do this even?
If there isnt, here the Problem:
i printed out the attacker and even printed it in a file to see what it actually returns. The txt file stays empty, and the print returns
NPC [104][npc_headcrab_black]
not sure what of that i am supposed to put in the if statement? I tryd the whole thing, 104, npc_headcrap_black, but it never works. And since thats the only thing that gets returned as attacker, which is also the thing that gets checked im not sure what to do.
Attacker is an entity. file.Write takes a string. Use attacker:GetClass() if you just want the "npc_headcrab_black"
Oh yea attacker:GetClass() works way better..
about the hook, i might try that later. Right now im still using the network code i had, just replaced the if statement with the GetClass().
Little problem wich i already noticed with the print(attacker), it prints out out twice. Same with the chat.AddText. It prints twice at the same time.
Which i simply assume, is happening because the poison headcrap attacks you twice? Or something
Sorry, you need to Log In to post a reply to this thread.