Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile("shared.lua")
- AddCSLuaFile("cl_init.lua")
- include("shared.lua")
- util.AddNetworkString("CanUse")
- util.AddNetworkString("WearIt")
- function ENT:Initialize() -- this is the pickup method which is basically a crate
- self:SetModel("models/props_junk/wood_crate001a.mdl")
- self:PhysicsInit(SOLID_VPHYSICS)
- self:SetMoveType(MOVETYPE_VPHYSICS)
- self:SetSolid(SOLID_VPHYSICS)
- self:SetUseType(SIMPLE_USE)
- local physObj = self:GetPhysicsObject()
- if (IsValid(physObj)) then
- physObj:Wake()
- physObj:EnableMotion(true)
- end
- end
- function ENT:Use(activator, caller) -- calling information to use later and setting abilities and model
- if !caller.isWearingArmor then
- caller.oldAgModel = caller:GetModel()
- caller.oldRunSpeed = caller:GetRunSpeed()
- caller.oldJumpPower = caller:GetJumpPower()
- caller.AgilityArmor = true
- caller.shouldFallDamageBeNegatedArmor = true
- caller.slightDamReduce = true
- caller:SetBloodColor( 3 )
- caller.isWearingArmor = true
- caller:SetModel("models/characters/nanosuit2/nanosuit_player.mdl") -- Model of the Agility Armor
- sound.Play( "items/battery_pickup.wav", caller:GetPos() )
- caller:SetRunSpeed(caller:GetRunSpeed() * 2.1)
- caller:SetJumpPower(caller:GetJumpPower() * 2.4)
- caller:SetHealth(450)
- caller:SetMaxHealth(450)
- caller:SetArmor(350)
- self:Remove()
- self:Remove()
- end
- end
- hook.Add("PlayerSay", "DropAgArmor", function(ply, text) -- hook to reset old arguments that we called earlier upon de-equipping
- if string.lower(text) == "/unequip" and ply.isWearingArmor then
- if (ply.AgilityArmor) then
- net.Start("CanUse")
- net.Send(activator)
- net.Receive("WearIt", function()
- ply.AgilityArmor = false
- ply.isWearingArmor = false
- ply.shouldFallDamageBeNegatedArmor = false
- ply.slightDamReduce = false
- ply:SetModel(ply.oldAgModel)
- ply:SetRunSpeed(ply.oldRunSpeed)
- ply:SetJumpPower(ply.oldJumpPower)
- ply:SetHealth(100)
- ply:SetArmor(0)
- local trace = {}
- trace.start = ply:EyePos()
- trace.endpos = trace.start + ply:GetAimVector() * 30
- trace.filter = ply
- ents.Create("agility_armor")
- local trl = util.TraceLine(trace)
- local pr = ents.Create("agility_armor")
- pr:SetPos(trl.HitPos)
- pr:Spawn()
- return ""
- end)
- end -- end if agility armor
- elseif string.lower(text) == "/unequip" and !ply.isWearingArmor then
- ply:ChatPrint("You are not wearing any suit.")
- end -- end main if
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement