Advertisement
Guest User

for Grampa, ggqf and others.

a guest
Oct 9th, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.13 KB | None | 0 0
  1. AddEntity("Health Dispenser", "health_dispenser", "models/props_combine/health_charger001.mdl", 1500, 1, "/buyhealthdispenser", TEAM_MEDIC)
  2. AddEntity("Armor Dispenser", "suit_dispenser", "models/props_combine/suit_charger001.mdl", 1500, 1, "/buyarmordispenser", TEAM_MEDIC)
  3.  
  4. ---------------------------------------------------------------------------------------------------------------------------------
  5. cl_init.lua {Health Dispenser}
  6. **
  7.  
  8. include("shared.lua")
  9.  
  10. function ENT:Draw()
  11.         self.Entity:DrawModel()
  12. end
  13.  
  14. ---------------------------------------------------------------------------------------------------------------------------------
  15. init.lua {Health Dispenser}
  16. **
  17.  
  18. AddCSLuaFile("cl_init.lua")
  19. AddCSLuaFile("shared.lua")
  20.  
  21. include("shared.lua")
  22.  
  23. function ENT:Initialize()
  24.         self:SetModel("models/props_combine/health_charger001.mdl")
  25.         self:PhysicsInit(SOLID_VPHYSICS)
  26.         self:SetMoveType(MOVETYPE_VPHYSICS)
  27.         self:SetSolid(SOLID_VPHYSICS)
  28.         local phys = self:GetPhysicsObject()
  29.         if phys and phys:IsValid() then phys:Wake() end
  30. end
  31.  
  32. function ENT:OnTakeDamage(dmg)
  33. end
  34.  
  35. function ENT:Use(activator,caller)
  36.         if activator:Health() < 100 then
  37.                 self:EmitSound("WallHealth.Start")
  38.                 activator:SetHealth(activator:Health() + 1)
  39.         end
  40. end
  41.  
  42. function ENT:Think()
  43. end
  44.  
  45.  
  46. ---------------------------------------------------------------------------------------------------------------------------------
  47. shared.lua {Health Dispenser}
  48. **
  49.  
  50. ENT.Type = "anim"
  51. ENT.Base = "base_gmodentity"
  52. ENT.PrintName = "Health Dispenser"
  53. ENT.Author = "Brightness"
  54. ENT.Spawnable = false
  55. ENT.AdminSpawnable = false
  56.  
  57.  
  58. ---------------------------------------------------------------------------------------------------------------------------------
  59. sleep.lua {Sleep/Unconscious mode}
  60. **
  61.  
  62. KnockoutTime = 5
  63.  
  64. local function ResetKnockouts(player)
  65.         player.SleepRagdoll = nil
  66.         player.KnockoutTimer = 0
  67. end
  68. hook.Add("PlayerSpawn", "Knockout", ResetKnockouts)
  69.  
  70.  
  71. function KnockoutToggle(player, command, args, caller)
  72.         if not player.SleepSound then
  73.                 player.SleepSound = CreateSound(player, "npc/ichthyosaur/water_breath.wav")
  74.         end
  75.        
  76.         if player:Alive() then
  77.                 if (player.KnockoutTimer and player.KnockoutTimer + KnockoutTime < CurTime()) or command == "force" then
  78.                         if (player.Sleeping and ValidEntity(player.SleepRagdoll)) then
  79.                                 player.OldHunger = player.DarkRPVars.Energy
  80.                                 player.SleepSound:Stop()
  81.                                 local ragdoll = player.SleepRagdoll
  82.                                 local health = player:Health()
  83.                                 player:Spawn()
  84.                                 player:SetHealth(health)
  85.                                 player:SetPos(ragdoll:GetPos())
  86.                                 player:SetAngles(Angle(0, ragdoll:GetPhysicsObjectNum(10):GetAngles().Yaw, 0))
  87.                                 player:UnSpectate()
  88.                                 player:StripWeapons()
  89.                                 ragdoll:Remove()
  90.                                 if player.WeaponsForSleep and player:GetTable().BeforeSleepTeam == player:Team() then
  91.                                         for k,v in pairs(player.WeaponsForSleep) do
  92.                                                 local wep = player:Give(v[1])
  93.                                                 player:RemoveAllAmmo()
  94.                                                 player:SetAmmo(v[2], v[3], false)
  95.                                                 player:SetAmmo(v[4], v[5], false)
  96.                                                
  97.                                                 wep:SetClip1(v[6])
  98.                                                 wep:SetClip2(v[7])
  99.                                                
  100.                                         end
  101.                                         local cl_defaultweapon = player:GetInfo( "cl_defaultweapon" )
  102.                                         if ( player:HasWeapon( cl_defaultweapon )  ) then
  103.                                                 player:SelectWeapon( cl_defaultweapon )
  104.                                         end
  105.                                         player:GetTable().BeforeSleepTeam = nil
  106.                                 else
  107.                                         GAMEMODE:PlayerLoadout(player)
  108.                                 end
  109.                                 player.WeaponsForSleep = {}
  110.                                 local RP = RecipientFilter()
  111.                                 RP:RemoveAllPlayers()
  112.                                 RP:AddPlayer(player)
  113.                                 umsg.Start("DarkRPEffects", RP)
  114.                                         umsg.String("colormod")
  115.                                         umsg.String("0")
  116.                                 umsg.End()
  117.                                 RP:AddAllPlayers()
  118.                                 if command == true then
  119.                                         player:Arrest()
  120.                                 end
  121.                                 player.Sleeping = false
  122.                                 player:SetDarkRPVar("Energy", player.OldHunger)
  123.                                 player.OldHunger = nil
  124.                                
  125.                                 if player.DarkRPVars.Arrested then
  126.                                         GAMEMODE:SetPlayerSpeed(player, GetConVarNumber("aspd"), GetConVarNumber("aspd") )
  127.                                 end
  128.                         else
  129.                                 for k,v in pairs(ents.FindInSphere(player:GetPos(), 30)) do
  130.                                         if v:GetClass() == "func_door" then
  131.                                                 Notify(player, 1, 4, string.format(LANGUAGE.unable, "sleep", "func_door exploit"))
  132.                                                 return ""
  133.                                         end
  134.                                 end
  135.  
  136.                                 player.WeaponsForSleep = {}
  137.                                 for k,v in pairs(player:GetWeapons( )) do
  138.                                         player.WeaponsForSleep[k] = {v:GetClass(), player:GetAmmoCount(v:GetPrimaryAmmoType()),
  139.                                         v:GetPrimaryAmmoType(), player:GetAmmoCount(v:GetSecondaryAmmoType()), v:GetSecondaryAmmoType(),
  140.                                         v:Clip1(), v:Clip2()}
  141.                                         /*{class, ammocount primary, type primary, ammo count secondary, type secondary, clip primary, clip secondary*/
  142.                                 end
  143.                                 local ragdoll = ents.Create("prop_ragdoll")
  144.                                 ragdoll:SetPos(player:GetPos())
  145.                                 ragdoll:SetAngles(Angle(0,player:GetAngles().Yaw,0))
  146.                                 ragdoll:SetModel(player:GetModel())
  147.                                 ragdoll:Spawn()
  148.                                 ragdoll:Activate()
  149.                                 ragdoll:SetVelocity(player:GetVelocity())
  150.                                 ragdoll.OwnerINT = player:EntIndex()
  151.                                 player:StripWeapons()
  152.                                 player:Spectate(OBS_MODE_CHASE)
  153.                                 player:SpectateEntity(ragdoll)
  154.                                 player.IsSleeping = true
  155.                                 player.SleepRagdoll = ragdoll
  156.                                 player.KnockoutTimer = CurTime()
  157.                                 player:GetTable().BeforeSleepTeam = player:Team()
  158.                                 --Make sure noone can pick it up:
  159.                                 ragdoll.Owner = player
  160.                                 local RP = RecipientFilter()
  161.                                 RP:RemoveAllPlayers()
  162.                                 RP:AddPlayer(player)
  163.                                 umsg.Start("DarkRPEffects",RP)
  164.                                         umsg.String("colormod")
  165.                                         umsg.String("1")
  166.                                 umsg.End()
  167.                                 RP:AddAllPlayers()
  168.                                 player.SleepSound = CreateSound(ragdoll, "npc/ichthyosaur/water_breath.wav")
  169.                                 player.SleepSound:PlayEx(0.10, 100)
  170.                                 player.Sleeping = true
  171.                         end
  172.                 end
  173.                 return ""
  174.         else
  175.                 Notify(player, 1, 4, string.format(LANGUAGE.disabled, "/sleep", ""))
  176.                 return ""
  177.         end
  178. end
  179. AddChatCommand("/sleep", KnockoutToggle)
  180. AddChatCommand("/wake", KnockoutToggle)
  181. AddChatCommand("/wakeup", KnockoutToggle)
  182.  
  183. local function DamageSleepers(ent, inflictor, attacker, amount, dmginfo)
  184.         local ownerint = ent.OwnerINT
  185.         if ownerint and ownerint ~= 0 then
  186.                 for k,v in pairs(player.GetAll()) do
  187.                         if v:EntIndex() == ownerint then
  188.                                 if attacker == GetWorldEntity() then
  189.                                         amount = 10
  190.                                         dmginfo:ScaleDamage(0.1)
  191.                                 end
  192.                                 v:SetHealth(v:Health() - amount)
  193.                                 if v:Health() <= 0 and v:Alive() then
  194.                                         v:Spawn()
  195.                                         v:UnSpectate()
  196.                                         v:SetPos(ent:GetPos())
  197.                                         v:SetHealth(1)
  198.                                         v:TakeDamage(1, inflictor, attacker)
  199.                                         if v.SleepSound then
  200.                                                 v.SleepSound:Stop()
  201.                                         end
  202.                                         ent:Remove()
  203.                                 end
  204.                         end
  205.                 end
  206.         end
  207. end
  208. hook.Add("EntityTakeDamage", "Sleepdamage", DamageSleepers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement