• help with suit code
    1 replies, posted
so i used mito's armors as a base from the workshop and i got to this and i simply dont understand why the hook for the drop dosent seem to work? it used to work and suddenly stopped then all of a sudden it works only when i click save again on the lua and then all of a sudden again after a restart or so it dosent anymore? im so confused i simply want people to be able to do /unequip and wait 8 seconds and the suit drops infront of them to pick it up with their inventory, what am i doing wrong? AddCSLuaFile("shared.lua") AddCSLuaFile("cl_init.lua") include("shared.lua") function ENT:Initialize() self:SetModel("models/items/item_item_crate.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 local equipSound = Sound("darkrp/nano_on.wav") function ENT:Use(activator, caller)     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    sound.Play( equipSound, self:GetPos()) caller:SetBloodColor( 3 ) caller.isWearingArmor = true caller:SetModel("models/characters/nanosuit2/nanosuit_player.mdl") -- Model of the Agility Armor caller:SetRunSpeed(caller:GetRunSpeed() * 1.5) caller:SetJumpPower(caller:GetJumpPower() * 1.9) caller:SetHealth(275) caller:SetArmor(1000) self:Remove() end end function GAMEMODE:PlayerFootstep( ply, pos, foot, sound, volume, filter) if CLIENT then if (ply:GetModel() == "models/player/marine1_tygus.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 75, math.random(50,100), volume, CHAN_BODY ) return true elseif (ply:GetModel() == "models/characters/nanosuit2/nanosuit_player.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 75, math.random(150,200), volume / 3, CHAN_BODY ) return true elseif (ply:GetModel() == "models/characters2/gnanosuit2/gnanosuit_player.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 75, math.random(150,200), volume / 3, CHAN_BODY ) return true elseif (ply:GetModel() == "models/player/legion/deadspace/advancedrig.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(50,100) or math.random(150,200), volume / 3, CHAN_BODY) return true elseif (ply:GetModel() == "models/player/legion/legionary_soldier.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(150,200) or math.random(200,255), volume / 2, CHAN_BODY) return true elseif (ply:GetModel() == "models/suno/player/blackburn.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(150,200) or math.random(200,255), volume / 2, CHAN_BODY) return true end else if (ply:GetModel() == "models/player/marine1_tygus.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 75, math.random(50,100), volume, CHAN_BODY) return true elseif (ply:GetModel() == "models/characters/nanosuit2/nanosuit_player.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 50, math.random(150,200), volume / 3, CHAN_BODY) return true elseif (ply:GetModel() == "models/characters2/gnanosuit2/gnanosuit_player.mdl") then ply:EmitSound((foot == 0) and "darkrp/jugger_step1.wav" or "darkrp/jugger_step2.wav", 50, math.random(150,200), volume / 3, CHAN_BODY) return true elseif (ply:GetModel() == "models/player/legion/deadspace/advancedrig.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(50,100) or math.random(150,200), volume / 3, CHAN_BODY) return true elseif (ply:GetModel() == "models/player/legion/legionary_soldier.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(150,200) or math.random(200,255), volume / 2, CHAN_BODY) return true elseif(ply:GetModel() == "models/suno/player/blackburn.mdl") then ply:EmitSound("darkrp/advancedcombatsuit_footstep.wav", 50, (foot == 0) and math.random(150,200) or math.random(200,255), volume / 2, CHAN_BODY) return true end end end hook.Add("PlayerSay", "DropAgArmor", function(ply, text) if (string.lower(text) == "/unequip") then     if (ply.AgilityArmor) then         ply:PrintMessage( HUD_PRINTTALK, "Your Suit Will Drop In 8 Seconds." )         timer.Simple( 8, function()         if (ply.AgilityArmor) then         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( 25 )         local trace = {}         trace.start = ply:EyePos()         trace.endpos = trace.start + ply:GetAimVector() * 30         trace.filter = ply         ents.Create("Nano Suit")         local trl = util.TraceLine(trace)         local pr = ents.Create("agility_armor")         pr:SetPos(trl.HitPos)         pr:Spawn()         return ""                 end             end)         end end end)
You should use hook.Add.
Sorry, you need to Log In to post a reply to this thread.