• Print

Author Topic: Freezing a prop/entity?  (Read 4225 times)

0 Members and 1 Guest are viewing this topic.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Freezing a prop/entity?
« on: February 10, 2015, 09:11:51 pm »
I can't appear to get a good answer upon the way I'm doing this, maybe someone here had a better idea than I do.

So basically, I'm trying to spawn a prop (which I found the only way to do so is by making it an entity) then have it frozen, and never move, ever. I have tried to disable motion, and also turn move type to none, but turning move type to none cause major issues.

This is my current testing code:
Code: Lua
  1. local button3 = ents.Create( "prop_physics" )
  2. if ( !IsValid( button3 ) ) then
  3. button3:Remove()
  4. return
  5. button3:SetModel( "models/hunter/plates/plate8x8.mdl" )
  6. button3:SetPos( Vector( 2668, 2882, -14333 ) )
  7. button3:Spawn()
  8. button3:SetMoveType(MOVETYPE_VPHYSICS)
  9. button3:EnableMotion(true)
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Freezing a prop/entity?
« Reply #1 on: February 10, 2015, 11:10:32 pm »
Code: [Select]

local phys = button3:GetPhysicsObject()
if phys and phys:IsValid() then
phys:EnableMotion(false) -- Freezes the object in place.
end
button3.permalocked = true

function PermaLock( ply, ent )
if ent.permalocked then return false end
end
hook.Add("PhysgunPickup", "PermaLock", PermaLock)




That will freeze it. As far as keeping it from being unfrozen, you'd need to write some kind of hook that prevents players from using the physgun on it. I have included both in the code above.
The part above the hook, add to your spawn code. As for the hook, just add the function somewhere to a serverside autorun file or init.lua if you're doing a gamemode.

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Freezing a prop/entity?
« Reply #2 on: February 10, 2015, 11:28:47 pm »
Code: [Select]

local phys = button3:GetPhysicsObject()
if phys and phys:IsValid() then
phys:EnableMotion(false) -- Freezes the object in place.
end
button3.permalocked = true

function PermaLock( ply, ent )
if ent.permalocked then return false end
end
hook.Add("PhysgunPickup", "PermaLock", PermaLock)




That will freeze it. As far as keeping it from being unfrozen, you'd need to write some kind of hook that prevents players from using the physgun on it. I have included both in the code above.
The part above the hook, add to your spawn code. As for the hook, just add the function somewhere to a serverside autorun file or init.lua if you're doing a gamemode.

Thank you, and solved once again by jesus.
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

  • Print