• Frozen Weapon
    12 replies, posted
Is it possible to make weapons on a map frozen so that people can still pick them up and use them, but they can't be moved around? Like, someone can pick up the weapon, but the weapons can't be moved around with gravguns and stuff.
Just an Idea, and maybe not the best but you could loop all the ents when the map loads and weld the weapons to world, or just freeze their physics objects. quick example, [lua] for k,v in pairs(ents.GetAll()) do if v:IsWeapon() then local vPhys = v:GetPhysicsObject() if !(vPhys == nil) and v:IsValid() then vPhys:EnableMotion(false) end end end [/lua] untested but that should freeze all weapons on the map. Just re-read your post, this way they could be picked up with the gravgun and physgun, but if you drop the vPhys stuff and replace it will a weld they should stay put until picked up.
[lua]for k,v in pairs(ents.GetAll()) do if v:IsWeapon() then v:SetMoveType(MOVETYPE_NONE) end end [/lua] or this
Sorry for the late response, but neither of those freeze the weapon. They actually don't change anything D:
bump.
EnableMotion should work fine, because if you can pickup the weapon with physics gun and freeze it then it should work.
I think what hes trying to ask, but lacks the grammar. "Is there a way to make a weapon dispenser that cant be moved, but players can walk up to it and use it/get a gun?"
[QUOTE=Remscar;30114790]I think what hes trying to ask, but lacks the grammar. "Is there a way to make a weapon dispenser that cant be moved, but players can walk up to it and use it/get a gun?"[/QUOTE] "Can you make weapons frozen but players can pick them up and use them"
[QUOTE=Buggzie;30115090]"Can you make weapons frozen but players can pick them up and use them"[/QUOTE] This. I want the weapons to be there, but I don't want people moving them around and hiding them. [lua]function GM:Initialize() for k,v in pairs(ents.GetAll()) do if v:GetClass() == "weapon_" then local vPhys = v:GetPhysicsObject() if !(vPhys == nil) and v:IsValid() then vPhys:EnableMotion(false) end end end end[/lua] This is what I have
Are you trying to do it to weapons that are in the map by default?
sorry for the very long bump, but yes. I'm trying to freeze all the weapons that were put on the map by the mapper.
[QUOTE=Cooldudex;30119426]This. I want the weapons to be there, but I don't want people moving them around and hiding them. [lua]function GM:Initialize() for k,v in pairs(ents.GetAll()) do if v:GetClass() == "weapon_" then local vPhys = v:GetPhysicsObject() if !(vPhys == nil) and v:IsValid() then vPhys:EnableMotion(false) end end end end[/lua] This is what I have[/QUOTE] It won't find a single weapon, since you're looking if the class is exactly "weapon_" which no weapon is. Try do [lua]if string.Left(v:GetClass(), 7) == "weapon_" then[/lua] instead.
Does weapon_* work? Or is that for NPC's only?
Sorry, you need to Log In to post a reply to this thread.