Background:
I'm am developing a deathrun server for the latest version of GMOD (13) and it seem's that none of the the previous code for Team No Collide works with the gamemode. Here are some of the code I have tried
[code]
function NoCollidePeople( teamID )
for _, ply in pairs( team.GetPlayers( teamID ) ) do
ply:SetNoCollideWithTeammates( true )
end
end
[/code]
[code]
function GM:ShouldCollide( ent1, ent2 )
if ent1:IsPlayer() and ent2:IsPlayer() then
return (ent1:Team() != ent2:Team())
end
return true
end
[/code]
Resolved:
Still not resolved, if anyone could please help me with this problem that would be much appreciated!
If that's not working you can try this to make all players not collide, although it's not team specific.
[code]for _, ply in pairs(player.GetAll()) do
ply:SetCollisionGroup(COLLISION_GROUP_WEAPON)
end[/code]
[QUOTE=hemirox;38605232]If that's not working you can try this to make all players not collide, although it's not team specific.
[code]for _, ply in pairs(player.GetAll()) do
ply:SetCollisionGroup(COLLISION_GROUP_WEAPON)
end[/code][/QUOTE]
Still didn't resolve the issue :/
In order for the ShouldCollide hook to be called for an entity, you need to do this:
[lua]
ent:SetCustomCollisionCheck( true ) -- in this case ent would be the player entity
[/lua]
[QUOTE=_nonSENSE;38608188]In order for the ShouldCollide hook to be called for an entity, you need to do this:
[lua]
ent:SetCustomCollisionCheck( true ) -- in this case ent would be the player entity
[/lua][/QUOTE]
Sorry ahead of time if im causing problems... Here is the code I have in the shared.lua file
[code] function GM:ShouldCollide( ent1, ent2 )
player:SetCustomCollisionCheck( true ) -- in this case ent would be the player entity
if ent1:IsPlayer() and ent2:IsPlayer() then
return (ent1:Team() != ent2:Team())
end
return true
end
[/code]
Still not causing players to no collide...
How do you expect the custom collision to work if you are enabling custom collision inside the custom collision function :v:
Just add it to the load out hook or something.
[QUOTE=Richtofen;38608332]Sorry ahead of time if im causing problems... Here is the code I have in the shared.lua file
[code] function GM:ShouldCollide( ent1, ent2 )
player:SetCustomCollisionCheck( true ) -- in this case ent would be the player entity
if ent1:IsPlayer() and ent2:IsPlayer() then
return (ent1:Team() != ent2:Team())
end
return true
end
[/code]
Still not causing players to no collide...[/QUOTE]
As far as we know player is not defined there, and even if it was that still wouldn't work.
What you want to do is use SetCustomCollisionCheck on the player the first time they spawn (PlayerInitialSpawn).
Can someone just give me the entire line of code and where to put it, i'm new to lua and this is confusing the heck out of me...
[lua]function GM:PlayerInitialSpawn(pl)
pl:SetCustomCollisionCheck(true)
end
function GM:ShouldCollide( ent1, ent2 )
if ent1:IsPlayer() and ent2:IsPlayer() then
return (ent1:Team() != ent2:Team())
end
end[/lua]
Only return false if necessary, don't always return something.
Right. Copied/pasted his code without looking at it.
You're still doing it.
[QUOTE=Map in a box;38609495]Only return false if necessary, don't always return something.[/QUOTE]
That would only apply if you were adding hooks since it will jut call the gamemode function in the end.
[QUOTE=Map in a box;38618803]You're still doing it.[/QUOTE]
It's necessary to return true there. Scenario: Player A and Player B are both on Team A. Hook returns false so they don't collide. Player A switches to Team B so collision is necessary.
If it didn't return anything then collision would remain ignored between the two. Given the gamemode doesn't handle it like it needs to.