Advertisement
Guest User

init.lua

a guest
May 22nd, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. AddCSLuaFile("shared.lua")
  2. AddCSLuaFile("cl_init.lua")
  3. include("shared.lua")
  4.  
  5. util.AddNetworkString("CanUse")
  6. util.AddNetworkString("WearIt")
  7.  
  8. function ENT:Initialize() -- this is the pickup method which is basically a crate
  9. self:SetModel("models/props_junk/wood_crate001a.mdl")
  10. self:PhysicsInit(SOLID_VPHYSICS)
  11. self:SetMoveType(MOVETYPE_VPHYSICS)
  12. self:SetSolid(SOLID_VPHYSICS)
  13. self:SetUseType(SIMPLE_USE)
  14. local physObj = self:GetPhysicsObject()
  15.  
  16. if (IsValid(physObj)) then
  17. physObj:Wake()
  18. physObj:EnableMotion(true)
  19. end
  20. end
  21.  
  22.  
  23. function ENT:Use(activator, caller) -- calling information to use later and setting abilities and model
  24. if !caller.isWearingArmor then
  25. caller.oldAgModel = caller:GetModel()
  26. caller.oldRunSpeed = caller:GetRunSpeed()
  27. caller.oldJumpPower = caller:GetJumpPower()
  28. caller.AgilityArmor = true
  29. caller.shouldFallDamageBeNegatedArmor = true
  30. caller.slightDamReduce = true
  31. caller:SetBloodColor( 3 )
  32. caller.isWearingArmor = true
  33. caller:SetModel("models/characters/nanosuit2/nanosuit_player.mdl") -- Model of the Agility Armor
  34. sound.Play( "items/battery_pickup.wav", caller:GetPos() )
  35. caller:SetRunSpeed(caller:GetRunSpeed() * 2.1)
  36. caller:SetJumpPower(caller:GetJumpPower() * 2.4)
  37. caller:SetHealth(450)
  38. caller:SetMaxHealth(450)
  39. caller:SetArmor(350)
  40.  
  41. self:Remove()
  42.  
  43. self:Remove()
  44. end
  45. end
  46.  
  47.  
  48. hook.Add("PlayerSay", "DropAgArmor", function(ply, text) -- hook to reset old arguments that we called earlier upon de-equipping
  49. if string.lower(text) == "/unequip" and ply.isWearingArmor then
  50. if (ply.AgilityArmor) then
  51. net.Start("CanUse")
  52. net.Send(activator)
  53. net.Receive("WearIt", function()
  54. ply.AgilityArmor = false
  55. ply.isWearingArmor = false
  56. ply.shouldFallDamageBeNegatedArmor = false
  57. ply.slightDamReduce = false
  58. ply:SetModel(ply.oldAgModel)
  59. ply:SetRunSpeed(ply.oldRunSpeed)
  60. ply:SetJumpPower(ply.oldJumpPower)
  61. ply:SetHealth(100)
  62. ply:SetArmor(0)
  63. local trace = {}
  64. trace.start = ply:EyePos()
  65. trace.endpos = trace.start + ply:GetAimVector() * 30
  66. trace.filter = ply
  67.  
  68. ents.Create("agility_armor")
  69. local trl = util.TraceLine(trace)
  70. local pr = ents.Create("agility_armor")
  71. pr:SetPos(trl.HitPos)
  72. pr:Spawn()
  73.  
  74. return ""
  75. end)
  76. end -- end if agility armor
  77. elseif string.lower(text) == "/unequip" and !ply.isWearingArmor then
  78. ply:ChatPrint("You are not wearing any suit.")
  79.  
  80.  
  81. end -- end main if
  82. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement