Advertisement
Darts

sv_hooks

Mar 21st, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. --[[
  2.     © 2012 Iron-Wall.org do not share, re-distribute or modify
  3.     without permission of its author (ext@iam1337.ru).
  4. --]]
  5.  
  6. local PLUGIN = PLUGIN;
  7.  
  8. function PLUGIN:PlayerSaveCharacterData(player, data)
  9.     if ( data["Lifes"] ) then
  10.         data["Lifes"] = math.Round( data["Lifes"]) or math.Round(Clockwork.config:Get("permadeath_lifes"):Get());
  11.     end;
  12. end;
  13.  
  14. function PLUGIN:PlayerRestoreCharacterData(player, data)
  15.     data["Lifes"] = data["Lifes"] or math.Round(Clockwork.config:Get("permadeath_lifes"):Get());
  16.     player.canSelectAny = false;
  17. end;
  18.  
  19. function PLUGIN:PlayerSetSharedVars(player, curTime)
  20.     player:SetSharedVar( "Lifes", math.Round(player:GetCharacterData("Lifes")));
  21. end;
  22.  
  23. function PLUGIN:PlayerCanSwitchCharacter(player, character)
  24.     if (!player:Alive() and !player:IsCharacterMenuReset() and player.canSelectAny) then
  25.         player.canSelectAny = false;
  26.         return true;
  27.     end;
  28. end;
  29.  
  30. function PLUGIN:PlayerDeath(player, inflictor, attacker, damageInfo)
  31.     local faction = player:GetFaction();
  32.    
  33.     if ( Clockwork.player:HasFlags(player, "d") ) then
  34.         return
  35.     end;
  36.    
  37.     if (!Clockwork.plugin:Call("CanPermaDeath", player, attacker)) then
  38.         return
  39.     end;
  40.    
  41.     if attacker:IsPlayer() then
  42.        
  43.         if (attacker == player and !Clockwork.config:Get("permedeath_suicide"):Get()) then
  44.             return
  45.         end;
  46.        
  47.         player.canSelectAny = true;
  48.        
  49.         Clockwork.player:Notify(player, "You are dead, create new character.");
  50.         self:PlayerDropAllItems(player, player:GetRagdollEntity());
  51.         self:PermaKillPlayer(player, player:GetRagdollEntity());
  52.         player:SetSharedVar("permakilled", true);
  53.     else
  54.         player:SetCharacterData( "Lifes", math.Clamp(player:GetCharacterData("Lifes") - 1, 0, math.Round(Clockwork.config:Get("permadeath_lifes"):Get())) );
  55.    
  56.         if (player:GetCharacterData("Lifes") < 1) then
  57.             player.canSelectAny = true;
  58.            
  59.             self:PlayerDropAllItems(player, player:GetRagdollEntity());
  60.             self:PermaKillPlayer(player, player:GetRagdollEntity());
  61.             player:SetSharedVar("permakilled", true);
  62.             Clockwork.player:Notify(player, "You are dead, create new character.");
  63.         else
  64.             Clockwork.player:Notify(player, "Lifes left: "..player:GetCharacterData("Lifes")..".");
  65.         end;
  66.     end;
  67. end;
  68.  
  69. -- You can edit this.
  70. function PLUGIN:CanPermaDeath( player, attacker )
  71.     local faction = player:GetFaction();
  72.  
  73.     if (faction == FACTION_CITIZEN) then
  74.         return true
  75.     end;
  76. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement