• Chat functions/damage from within SENT
    3 replies, posted
Well the title is pretty self-explanatory. I just picked up an age-old project that I was working on, and one of the immediate bugs I encountered was a custom SENT I created (from scratch) using chat functions from within the SENT (which now, after revisiting the project, is making itself clear that it's probably bad design). All these chat functions do are to tell the user they've destroyed the SENT instance. Everything works fine locally, but not when deployed to the dedi-server. The second bug that is quite similar is the fact that damaging the SENT works when playing locally but not when playing off of the dedi server. Everything else about the SENT works fine, other than the damage+kill and the chat functions. Here is the SENT death hook: [lua]-- If killed is false, it was used up and not destroyed function ENT:Death(killed, attacker) self:EmitSound("advantage/medic_packs/destroy.wav") self:Remove() if(killed == 0) then for k,v in pairs(self.CurrentPlayers) do if(v != self:GetNWEntity("EOwner")) then v:ChatPrint("A medic kit you are using has been used up.") end end self:GetNWEntity("EOwner"):ChatPrint("One of your medic packs has been used up.") elseif(killed == 1) then if(attacker != self:GetNWEntity("EOwner")) then attacker:ChatPrint("You have destroyed a medic pack.") self:GetNWEntity("EOwner"):ChatPrint("One of your medic packs has been destroyed.") else attacker:ChatPrint("You have destroyed your own medic pack.") end elseif(killed == 2) then for k,v in pairs(self.CurrentPlayers) do if(v != self:GetNWEntity("EOwner")) then v:ChatPrint("The owner of one of the medic packs you are using has been killed.") end end end end [/lua] Any help?
A problem that I can see, is that you are running a remove function before running the rest of the code. You are deleting the instance before running the rest of the code. Lua runs top to bottom. So the self:Remove needs to be at the end of the ENT:Death event. Another thing... Make sure you are using an actual hook. You can view them [URL="http://wiki.garrysmod.com/?title=Entity_Hooks"]here[/URL]. T[URL="http://wiki.garrysmod.com/?title=Entity_Hooks"][/URL]hat is a list of all of the hooks for Entity's.
You're running chatprint serverside.
[QUOTE=Mister C;33195698]A problem that I can see, is that you are running a remove function before running the rest of the code. You are deleting the instance before running the rest of the code. Lua runs top to bottom. So the self:Remove needs to be at the end of the ENT:Death event. Another thing... Make sure you are using an actual hook. You can view them [URL="http://wiki.garrysmod.com/?title=Entity_Hooks"]here[/URL]. T[URL="http://wiki.garrysmod.com/?title=Entity_Hooks"][/URL]hat is a list of all of the hooks for Entity's.[/QUOTE] True; however, I don't think it matters since calling Self:Remove() doesn't make the function return. Like I said, it works fine when I run it locally (indicating that that's not the problem). [QUOTE=skullorz;33197567]You're running chatprint serverside.[/QUOTE] That would most likely be the issue now that I'm looking at it. However, 1) it wouldn't explain why there is no damage being done, and 2) ChatPrint is shared, so while it may not print to someone else's console, it would still print to the localplayer's console.
Sorry, you need to Log In to post a reply to this thread.