I'm quite new to lua and I am currently trying to edit Divrans Evolve admin plugin called trainfuck to be a container that gets launched down ontop of the player, I got that part done but I have no idea how to make the container not collide with any props and still collide with the player.
You should use the [b][url=wiki.garrysmod.com/?title=Gamemode.ShouldCollide]Gamemode.ShouldCollide [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] hook to do that.
Thanks, could you give me an example of how to use this? I've never really used hooks before.
[QUOTE=Paulendy;24136281]Thanks, could you give me an example of how to use this? I've never really used hooks before.[/QUOTE]
Did you even click the link?
[lua]
local function ShouldCollideTestHook( ent1, ent2 )
if ( ent1:IsPlayer() and ent2:IsPlayer() ) then
return false --Returning false makes the entities collide with eachother
end
-- DO NOT RETURN FALSE HERE OR YOU WILL FORCE EVERY OTHER ENTITY TO COLLIDE
end
hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )
[/lua]
Because if you did then you would have seen this
[QUOTE=King Flawless;24138614]Did you even click the link?
[lua]
local function ShouldCollideTestHook( ent1, ent2 )
if ( ent1:IsPlayer() and ent2:IsPlayer() ) then
return false --Returning false makes the entities collide with eachother
end
-- DO NOT RETURN FALSE HERE OR YOU WILL FORCE EVERY OTHER ENTITY TO COLLIDE
end
hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )
[/lua]
Because if you did then you would have seen this[/QUOTE]
I did but I don't understand how I can use this to make the container not collide with any props...
[lua]
local function ShouldCollideTestHook( ent1, ent2 )
if ( ent1 == container and ent2:IsPlayer() ) or ( ent1:IsPlayer and ent2 == container ) then
return false
elseif (ent1 == container) or (ent2 == container) then
return true
end
end
hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )
[/lua]
Not sure about this, but in my mind, it works. Haven't tested it. Replace container with what the container actually is.
[QUOTE=PortalGod;24139132][lua]
local function ShouldCollideTestHook( ent1, ent2 )
if ( ent1 == container and ent2:IsPlayer() ) or ( ent1:IsPlayer and ent2 == container ) then
return false
elseif (ent1 == container) or (ent2 == container) then
return true
end
end
hook.Add( "ShouldCollide", "ShouldCollideTestHook", ShouldCollideTestHook )
[/lua]
Not sure about this, but in my mind, it works. Haven't tested it. Replace container with what the container actually is.[/QUOTE]
You should use ent1:GetClass() == "container" if it's an entity.
Sorry, you need to Log In to post a reply to this thread.