Zip Ties, Un-Tie Players on Death

So earlier I asked for assistance in altering my Zip Ties, now I have noticed another issue. Players who are killed while zip-tied remain zip-tied into the next life. They can run full speed and switch weapons and what not, but some actions, such as picking up weapons are restricted. I was curious how I would go about making it so the script would end/set the player un-tied if they were to die. Here is the code involved:

Would this function do it?



--- Again I have very limited LUA knowledge and even scraping this up took me a good 15 minutes to figure out something that actually sounded remotely right.
function meta:DeadPlayer
if  ply.nextspawn and Entity:IsTied() then
return self.TiedUp = false
end

Hook into PlayerDeath and then check if they’re tied, and if so, un-tie them.



hook.Add("PlayerDeath", "untieDeath", function(p)
   if (p:IsTied()) then
      p:UntiePlayer(p);
   end
end);


Also a personal note here, your function names are a bit silly and so is the layout of your function declarations.



target:TieUpPlayer(player_tying_me_up)


Is silly. It should either be:



target:TieUp(player_tying_me_up)


Or:



player_tying_me_up:TieUpPlayer(target)


But its just a personal preference. Also you might want to look into GM:FindUseEntity or GM:PlayerUse for your “E to tie” thingy.

I am stupid, if I add this to the LUA file, it is not shared.lua, would it require a map change to take effect?

There are a few ways of reloading scripts but for simplicity I think you should restart the server.

That did not work :confused:

Care to be a little more specific?

Players remain tied on respawn.

Ok I’v amended the code. Try this:



hook.Add("PlayerDeath", "untieDeath", function(p)
   print("Player has died.");
   if (p:IsTied()) then
      print("Player is tied... untying");
      p:UntiePlayer(p);
   end
end);


Tell us what it prints in the console.

Nothing is printed in console. Does this function need to go in lua/autorun/server? Currently I have it in the code with the other stuff. http://puu.sh/auaSt/7dc964b1e1.png

Ye sorry, PlayerDeath is a server-side hook.

So could I put it in an if (SERVER) then and be fine?

Yes as long as the script is also being run on the server.



if (SERVER) then
hook.Add("PlayerDeath", "untieDeath", function(p)
   print("Player has died.");
   if (p:IsTied()) then
      print("Player is tied... untying");
      p:UntiePlayer(p);
   end
end);
end


Still not functioning and nothing printing in console. The file is being used on the server as well.

Where is the file located? The hook should be called whenever someone dies and if it isnt, its probably not being run.

I did it for him. The UntiePlayer function had EVERYTHING in a timer, so it’s useless when you want to untie a player immediately.

I just added a PlayerDeath hook with the relevant code to untie the player (set the var to false)

The code was put in a file called “arrest.lua”, which is serverside.

Nicely done.