• Entity Help (Reverting use changes)
    4 replies, posted
hey, im hell new to lua and have being messing around with entities i wanted to know if there is a way to revert changes when an entity is used, what im trying to do is make a juggernaut suit for darkrp and i need a way for it to be taken off. currently it sets the playermodel, armor, runspeed and walkspeed. i want to know if there is a way to revert this with a keybind or chat command thing. i want it reverted not just changed because if it just changes back the playermodel to some other model then the job using it will lose their model.
You might want something like this: function ENT:Use(ply) ply.beforeJug = { Armor = ply:Armor(), RunSpeed = ply:GetRunSpeed(), WalkSpeed = ply:GetWalkSpeed(), Model = ply:GetModel() } ply:SetArmor(200) ply:SetRunSpeed(150) ply:SetWalkSpeed(110) ply:SetModel( "models/player/combine_super_soldier.mdl" ) self:Remove() end // use console command 'removeJuggernaut' to remove juggernaut: concommand.Add("removeJuggernaut", function(ply) if !ply.beforeJug then return end ply:SetArmor(ply.beforeJug.Armor) ply:SetRunSpeed(ply.beforeJug.RunSpeed) ply:SetWalkSpeed(ply.beforeJug.WalkSpeed) ply:SetModel( ply.beforeJug.Model ) ply.beforeJug = nil end)
thanks a bunch dude! any idea how i could make it print something in chat to the activator of the suit? function ENT:Use(ply) ply.beforeJug = { Armor = ply:Armor(), RunSpeed = ply:GetRunSpeed(), WalkSpeed = ply:GetWalkSpeed(), Model = ply:GetModel() } PrintMessage( HUD_PRINTTALK, "Type 'removesuit' in console to take off the Juggernaut Suit (this destroys it)" ) ply:SetArmor(200) ply:SetHealth(200) ply:SetRunSpeed(150) ply:SetWalkSpeed(110) ply:SetModel( "models/player/combine_super_soldier.mdl" ) self:Remove() end // use console command 'removesuit' to remove juggernaut: concommand.Add("removesuit", function(ply) if !ply.beforeJug then return end ply:SetArmor(ply.beforeJug.Armor) ply:SetRunSpeed(ply.beforeJug.RunSpeed) ply:SetWalkSpeed(ply.beforeJug.WalkSpeed) ply:SetModel( ply.beforeJug.Model ) ply.beforeJug = nil PrintMessage( HUD_PRINTTALK, "Juggernaut Suit removed" ) end)
Use ply:PrintMessage( enum, msg )
Thanks
Sorry, you need to Log In to post a reply to this thread.