I've searched endlessly for this script, but I can't find it.
What I want is, when you physgun a prop, it gets ghosted so you can't prop minge.
Any solutions? I've tried FPP, can't find the option.
The option in FPP has just been removed. It was buggy.
This should work, hasn't been tested. Try both server and client side before saying it doesn't work.
[lua]
function GM:OnPhysgunPickup(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,200)
end
function GM:OnPhysgunDrop(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,255)
end
[/lua]
All that does is change the transparency.
[code]
function GM:OnPhysgunPickup(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,150)
ent:GetPhysicsObject():EnableCollisions(true)
end
function GM:OnPhysgunDrop(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,255)
ent:GetPhysicsObject():EnableCollisions(true)
end
[/code]
That should work anyway, stole mdews code :)
[QUOTE=foxxeh;25877779][code]
function GM:OnPhysgunPickup(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,150)
ent:GetPhysicsObject():EnableCollisions(true)
end
function GM:OnPhysgunDrop(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,255)
ent:GetPhysicsObject():EnableCollisions(true)
end
[/code]
That should work anyway, stole mdews code :)[/QUOTE]
Theres no difference in the lua blocks after the functions at all, shouldn't the first one be
[lua] ent:GetPhysicsObject():EnableCollisions(false) [/lua]
?
[code]
function GM:OnPhysgunPickup(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,150)
ent:GetPhysicsObject():EnableCollisions(false)
end
function GM:OnPhysgunDrop(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() then return false end
ent:SetColor(255,255,255,255)
ent:GetPhysicsObject():EnableCollisions(true)
end
There we go!
So do I just put this into a random.lua file and stuff it in autorun?
If it's a specific lua, could you state that? Thanks alot fp.
[editline]6th November 2010[/editline]
Well adding on, putting it in autorun it can't index GM, returning as a nil value.
[QUOTE=Jaastin;25892111]So do I just put this into a random.lua file and stuff it in autorun?
If it's a specific lua, could you state that? Thanks alot fp.
[editline]6th November 2010[/editline]
Well adding on, putting it in autorun it can't index GM, returning as a nil value.[/QUOTE]
The GM stands for gamemode, if you're not making a gamemode then you just have to do it like hook.Add("OnPhysgunDrop", ............
Should work, untested.
[lua]function REQOnPhysgunPickup(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() or ent:IsNpc() or ent:IsBot() then return false end
ent:SetColor(255,255,255,150)
ent:GetPhysicsObject():EnableCollisions(false)
end
function REQOnPhysgunDrop(ent, mdl)
if ent:IsWorld() or ent:IsPlayer() or ent:IsNpc() or ent:IsBot() then return false end
ent:SetColor(255,255,255,255)
ent:GetPhysicsObject():EnableCollisions(true)
end
hook.Add( "OnPhysgunPickup", "REQOnPhysgunPickup", REQOnPhysgunPickup)
hook.Add( "OnPhysgunDrop", "REQOnPhysgunDrop", REQOnPhysgunDrop) [/lua]
put it in garrysmod/garrysmod/lua/autorun/server/random.lua
As an addon on singleplayer, the above script does not work.
[QUOTE=Jaastin;25892648]As an addon on singleplayer, the above script does not work.[/QUOTE]
Well I've never tested anything in singleplayer before, any errors?
EDIT: my fault for copying the code blocks above, the function was wrong.
EDIT2: the parameters were also wrong, sigh, use the following edited code.
EDIT3: this makes it shorter, really...should be last edit.
[lua]
local valobject = ent:GetPhysicsObject()
function REQPhysgunPickup(ply, ent)
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,150)
valobject:EnableCollisions(false)
end
function REQPhysgunDrop(ply, ent)
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,255)
valobject:EnableCollisions(false)
end
hook.Add( "PhysgunPickup", "REQPhysgunPickup", REQPhysgunPickup)
hook.Add( "PhysgunDrop", "REQPhysgunDrop", REQPhysgunDrop)[/lua]
Just put mine in like cl_init.lua in your gamemodes folder... It's a lot easier.
Not working for me.
[QUOTE=mdew355;25892921]Just put mine in like cl_init.lua in your gamemodes folder... It's a lot easier.[/QUOTE]
If you had read my post you would know yours wouldn't have worked, and I'll tell you why:
OnPhysgunDrop/Pickup is NOT a function.
what you defined as "ent" was actually a player, so you were trying to check if a player was the world or a player, and then if it wasn't try to set the colour and the collision for that player (I assume player is the one holding the physgun)
@ mdew355
Doesn't work in cl_init @ single player
@ zeph
Doesn't work in lua/autorun/server
[QUOTE=Jaastin;25893020]@ mdew355
Doesn't work in cl_init @ single player
@ zeph
Doesn't work in lua/autorun/server[/QUOTE]
Then give me the errors that pop up in your console, saying it doesn't work doesn't help me as much as the errors would.
Zephilinox you putted valobject outside the hook, and the 'ent' object does not exist yet, put it inside the hook.
[QUOTE=Jaastin;25893020]@ mdew355
Doesn't work in cl_init @ single player
@ zeph
Doesn't work in lua/autorun/server[/QUOTE]
Just download source dedicated server and install Garry's Mod in it. If you're going to code lua scripts server-side you don't want to do that in shitty single player.
[QUOTE=leiftiger;25893068]Zephilinox you putted valobject outside the hook, and the 'ent' object does not exist yet, put it inside the hook.[/QUOTE]
If I put the variable inside the function, then that variable would only apply to that function, if I take it out the function, I can use that variable anywhere inside the lua file.
At least thats what the tutorials say.
Ok, now you all lost me. What the hell should this file look like then?
[QUOTE=Zephilinox;25893126]If I put the variable inside the function, then that variable would only apply to that function, if I take it out the function, I can use that variable anywhere inside the lua file.
At least thats what the tutorials say.[/QUOTE]
Put the variable in both functions, the entity object does not exist outside of the hook! You will not be able to get a physics object from it.
This would be the correct example:
[lua]
function REQPhysgunPickup(ply, ent)
local valobject = ent:GetPhysicsObject()
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,150)
valobject:EnableCollisions(false)
end
function REQPhysgunDrop(ply, ent)
local valobject = ent:GetPhysicsObject()
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,255)
valobject:EnableCollisions(true)
end
hook.Add( "PhysgunPickup", "REQPhysgunPickup", REQPhysgunPickup)
hook.Add( "PhysgunDrop", "REQPhysgunDrop", REQPhysgunDrop)[/lua]
[QUOTE=leiftiger;25893141]Put the variable in both functions, the entity object does not exist outside of the hook! You will not be able to get a physics object from it.
This would be the correct example:
[lua]
function REQPhysgunPickup(ply, ent)
local valobject = ent:GetPhysicsObject()
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,150)
valobject:EnableCollisions(false)
end
function REQPhysgunDrop(ply, ent)
local valobject = ent:GetPhysicsObject()
if !valobject:IsValid() then return false end
ent:SetColor(255,255,255,255)
valobject:EnableCollisions(false)
end
hook.Add( "PhysgunPickup", "REQPhysgunPickup", REQPhysgunPickup)
hook.Add( "PhysgunDrop", "REQPhysgunDrop", REQPhysgunDrop)[/lua][/QUOTE]
defeats the purpose of having the variable, which is to re-use it. But yeah, if its because of the variable, then putting it inside the function would work, try that banana lord/jaastin, in a lua file @ garrysmod/garrysmod/lua/autorun/server
My prop is now under the map
lol
[editline]6th November 2010[/editline]
Also, that code has on the drop valobject:EnableCollisions(false), it needs to be true.
[QUOTE=Banana Lord.;25893220]My prop is now under the map
lol
[editline]6th November 2010[/editline]
Also, that code has on the drop valobject:EnableCollisions(false), it needs to be true.[/QUOTE]
I must have mistook it for the first function when I was editting it in the quick reply box, heh :P
So is there any way to stop this from letting my props go through worldspawn?
SEt it to Collision GRoup DEbris, and then back to VPhysics
I can't tell if somehow that message was code for something, with the random caps and all.
Thanks.
You could use COLLISION_GROUP_WORLD, that will make the entity only collide with world
[lua]
function REQPhysgunPickup(ply, ent)
if !ent:IsValid() then return false end
ent:SetColor(255,255,255,150)
ent.OldColGroup = ent:GetCollisionGroup()
ent:SetCollisionGroup(COLLISION_GROUP_WORLD)
end
function REQPhysgunDrop(ply, ent)
if !ent:IsValid() then return false end
ent:SetColor(255,255,255,255)
if ent.OldColGroup then
ent:SetCollisionGroup(ent.OldColGroup)
end
end
hook.Add( "PhysgunPickup", "REQPhysgunPickup", REQPhysgunPickup)
hook.Add( "PhysgunDrop", "REQPhysgunDrop", REQPhysgunDrop)[/lua]
What if I wanted it to collide with windows and stuff too?
Sorry, you need to Log In to post a reply to this thread.