• How to 'kill' a player when they're already dead -TTT-
    9 replies, posted
Is there a way to kill someone or maybe reset the player in TTT after they've died? Reason is, the player is dead due to an ongoing effect and once they die they keep that effect. It doesn't stop till they suicide, so how can I achieve this? ply:Kill() doesn't work. [CODE] local function PoisonHit() timer.Create('zeus_poison', 1, 0, function() for k, ply in pairs(player.GetAll()) do -- Check if target is already poisoned if ply:IsPoisoned() then -- Poisoned target is dead. if ply:Health() <= 0 then ply:ClearPoisonSounds() -- make sure target is dead ply:Kill() end ply:PoisonHit(2) end end end) end hook.Add("Initialize", "zeus.PoisonHit", PoisonHit)[/CODE]
Use PlayerDeath hook to clear the effect? Clear the effect in IsPoisoned or in PoisonHit when then the player is dead?
I think that did it thanks, I doubt i made it simple but I ended up with this [CODE]local function RemovePoison() for k, ply in pairs(player.GetAll()) do ply:ClearPoisonHit() ply:ClearPoisonSounds() end end hook.Add("PlayerDeath", "zeus.RemovePoison", RemovePoison)[/CODE]
That would remove the poison from all players when one dies, and the syntax is wrong - you forgot an "end" before hook.Add
Instead of removing it from all players, when the player is poisoned add that players steamid/uniqueid to a table and then check if any players id in the table is dead and if they are then remove the effect. Also to freakyy unless im blind or just stupid it looks fine [editline]16th March 2014[/editline] also dont forget to remove them once they are dead
[QUOTE=freakyy;44249959]and the syntax is wrong - you forgot an "end" before hook.Add[/QUOTE] [QUOTE=_Jacob;44250126]Also to freakyy unless im blind or just stupid it looks fine[/QUOTE] It is fine, the tabbing is just fucked up
[QUOTE=_Jacob;44250126]Instead of removing it from all players, when the player is poisoned add that players steamid/uniqueid to a table and then check if any players id in the table is dead and if they are then remove the effect. Also to freakyy unless im blind or just stupid it looks fine [editline]16th March 2014[/editline] also dont forget to remove them once they are dead[/QUOTE] Is it even possible to check if a player is dead from a steamID?
[QUOTE=mortuus;44252526]Is it even possible to check if a player is dead from a steamID?[/QUOTE] Yes.
[QUOTE=mortuus;44252526]Is it even possible to check if a player is dead from a steamID?[/QUOTE] Its not efficient, you will have to loop through the whole player table to find the correct player which the steamid is assigned to. You should set the entity of the player instead, such as: [lua]local deadplayers = {} function KillPlayer( Player ) deadplayers[ Player ] = true // or table.insert( deadplayers, Player ) end // and use if deadplayers[ Player ] then // or if table.HasValue( deadplayers, Player ) then[/lua]
Sorry, you need to Log In to post a reply to this thread.