How would I make it so props automatically have their collisions disabled when being physgunned, and when inside another prop if both aren't frozen?
If you know lua, you'll need these:
[URL]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/URL]
[url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url]
[URL]http://wiki.garrysmod.com/page/Entity/SetCollisionGroup[/URL]
[URL]http://wiki.garrysmod.com/page/PhysObj/EnableMotion[/URL]
If you don't - You can hire someone to write the script for you.
[QUOTE=Netheous;48764725]If you know lua, you'll need these:
[URL]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/URL]
[url]http://wiki.garrysmod.com/page/GM/PhysgunDrop[/url]
[URL]http://wiki.garrysmod.com/page/Entity/SetCollisionGroup[/URL]
[URL]http://wiki.garrysmod.com/page/PhysObj/EnableMotion[/URL]
If you don't - You can hire someone to write the script for you.[/QUOTE]
As yes the wonderful scriptfodder.
Maybe I would if I wasn't banned from it.
[editline]27th September 2015[/editline]
I tried doing this, but it does literally nothing.
/addons/propcollide/lua/autorun/server/propcollide.lua should do it right?
[CODE]function AutoNoCollide( ent )
if ent == "prop_physics" then
Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/CODE]
[QUOTE=Sweepyoface;48770318]As yes the wonderful scriptfodder.
Maybe I would if I wasn't banned from it.
[editline]27th September 2015[/editline]
I tried doing this, but it does literally nothing.
/addons/propcollide/lua/autorun/server/propcollide.lua should do it right?
[CODE]function AutoNoCollide( ent )
if ent == "prop_physics" then
Entity:SetCollisionGroup(COLLISION_GROUP_NONE)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/CODE][/QUOTE]
You are executinng SetCollisionGroup on an unexistant entity (Entity)
[QUOTE=Netheous;48764725]You can hire someone to write the script for you.[/QUOTE]
They say to nudge people in the right direction — [I]not shove them off a bridge[/I] :v:
Anyway, make sure you add a PhysgunDrop hook, too, to set it to its original collision group, unless that's not what you want.
[QUOTE=Z0mb1n3;48771097]They say to nudge people in the right direction — [I]not shove them off a bridge[/I] :v:
Anyway, make sure you add a PhysgunDrop hook, too, to set it to its original collision group, unless that's not what you want.[/QUOTE]
I know, I'm just testing this first.
[CODE]
function AutoNoCollide( ent )
if ent == "prop_physics" then
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/CODE]
Doesn't work either. Pretty sure I have to define ent, can someone help me?
Your if check is wrong, you have to use this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetClass]Entity:GetClass[/url]
[QUOTE=Z0mb1n3;48771097]They say to nudge people in the right direction — [I]not shove them off a bridge[/I] :v:
Anyway, make sure you add a PhysgunDrop hook, too, to set it to its original collision group, unless that's not what you want.[/QUOTE]
Your point being? I gave him a set of links to functions/hooks he needs.
[QUOTE=Netheous;48771661]Your point being? I gave him a set of links to functions/hooks he needs.[/QUOTE]
No no, it was supposed to be a joke. You very "subtly" hinted at him hiring you to do the script for him, but I guess it wasn't executed very well.
Got this, getting attempt to index global LocalPlayer (nil)
[code]function AutoNoCollide( ent )
if ( LocalPlayer:GetEyeTrace().Entity == "prop_physics" ) then
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/code]
[QUOTE=SteppuFIN;48771378]Your if check is wrong, you have to use this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/GetClass]Entity:GetClass[/url][/QUOTE]
And you have already the ent in the function,
ent:GetClass() == "prop_physics"
[QUOTE=Sweepyoface;48783752]Got this, getting attempt to index global LocalPlayer (nil)
[code]function AutoNoCollide( ent )
if ( LocalPlayer:GetEyeTrace().Entity == "prop_physics" ) then
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/code][/QUOTE]
LocalPlayer is a function, not a variable.
Did you read the wiki page for this hook? As it takes the entity using the physgun as a first argument, so no need for localplayer business
[url]http://wiki.garrysmod.com/page/GM/PhysgunPickup[/url]
[code]function AutoNoCollide( ent )
if ent:GetClass() == "prop_physics" then
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
end
end
hook.Add( "PhysgunPickup", "Auto Nocollide", AutoNoCollide )[/code]
Does nothing.
Because the first argument is the player, THEN the entity, jesus!
What?
Did you learn GLua/Lua at all? Functions got arguments, and the PhysgunPickup got two arguments, the first is the player picking the entity up, the second is the entity that has been picked up.
Edit: Functions count to the basics of lua..
[QUOTE=Z0mb1n3;48773766]No no, it was supposed to be a joke. You very "subtly" hinted at him hiring you to do the script for him, but I guess it wasn't executed very well.[/QUOTE]
I couldn't care less about him hiring me.
How would I make it so if props are welded together all the welded props are also nocollided while being physgunned? [url]http://pastebin.com/YcskyzEw[/url]
The [URL="http://wiki.garrysmod.com/page/Main_Page"]Wiki[/URL] is a wonderful place. A quick search for "constraint" reveals the wonderful function [URL="http://wiki.garrysmod.com/page/constraint/GetAllConstrainedEntities"]constraint/GetAllConstrainedEntities[/URL] which returns a table of all the entities constrained to a specific entity (suprising, I know). It even includes a code snippet which loops through each entity. This can be re-purposed for what you want to achieve.
[CODE]
-- Loop through all the entities in the system
for _, Entity in pairs( constraint.GetAllConstrainedEntities( trace.Entity ) ) do
DoRemoveEntity( Entity )
end
[/CODE]
[URL="http://hastebin.com/uzaseferec.lua"]Something to get you started[/URL] (no clue if it still works)
Should be fairly simple to get constraint resolution in there, as roastchicken posted.
Thank you, although this isn't doing anything to the welded props. It worked when I put it in first, then when I integrated it into all the functions it stopped working.
[url]http://pastebin.com/QvtwTLQp[/url]
[editline]3rd October 2015[/editline]
Also how would I make props not un-nocollide if another prop or player is inside them? Something like:
[code]
function ENT:PhysicsCollide( data, phys )
if ent:GetClass() == "prop_physics"
end[/code]
?
[QUOTE=Sweepyoface;48815528]
Also how would I make props not un-nocollide if another prop or player is inside them?
[/QUOTE]
See the example [URL="http://wiki.garrysmod.com/page/util/TraceEntity"]here[/URL].
[QUOTE=MPan1;48824365]See the example [URL="http://wiki.garrysmod.com/page/util/TraceEntity"]here[/URL].[/QUOTE]
Kinda have no idea how to implement that into my code.
[code]function AutoUnNoCollide( ply, ent )
local phys = ent:GetPhysicsObject()
local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent }
local tr = util.TraceEntity( trace, ent )
timer.Simple( (PropMingeConfig.NocollidedTime), function()
if (PropMingeConfig.EnableAutoNocollide) then
if not ( tr.Hit ) then[/code]
Doesn't work.
[editline]8th October 2015[/editline]
How do I use local variables in other funcs? For example I have the prop set back to its original color after the alpha is set to 200 while being physgunned, but I want the alpha to be set to the original one too, not just 255.
[editline]8th October 2015[/editline]
Not quite sure how to word this, but how do I save an entity variable for use later in a different function?