• Does Player.SetNoCollideWithTeammates works now?
    9 replies, posted
I don't have time to test it right now so I'm asking if now the Player.SetNoCollideWithTeamates function works because in the wiki it says otherwise. [url]http://wiki.garrysmod.com/?title=Player.SetNoCollideWithTeammates[/url]
[QUOTE=CrashLemon;16780549]I don't have time to test it right now so I'm asking if now the Player.SetNoCollideWithTeamates function works because in the wiki it says otherwise. [url]http://wiki.garrysmod.com/?title=Player.SetNoCollideWithTeammates[/url][/QUOTE] If it doesn't work you can just use the function GM.ShouldCollide(entA, entB) to do that instead. So, let's say you didn't want players from the same team to collide, it would be something like this: [LUA] function GM:ShouldCollide(entA, entB) if !entA:IsPlayer() || !entB:IsPlayer() || entA:Team() == entB:Team() then return true end return false end [/LUA] Untested, but it should work.
[QUOTE=Silverlan;16781164]If it doesn't work you can just use the function GM.ShouldCollide(entA, entB) to do that instead. So, let's say you didn't want players from the same team to collide, it would be something like this: [LUA] function GM:ShouldCollide(entA, entB) if !entA:IsPlayer() || !entB:IsPlayer() || entA:Team() == entB:Team() then return true end return false end [/LUA] Untested, but it should work.[/QUOTE] I haven't tested it either, but you can short that function a little. [LUA] function GM:ShouldCollide(entA, entB) return (!entA:IsPlayer() || !entB:IsPlayer() || entA:Team() == entB:Team()) end [/LUA]
[QUOTE=Silverlan;16781164]If it doesn't work you can just use the function GM.ShouldCollide(entA, entB) to do that instead. So, let's say you didn't want players from the same team to collide, it would be something like this: [LUA] function GM:ShouldCollide(entA, entB) if !entA:IsPlayer() || !entB:IsPlayer() || entA:Team() == entB:Team() then return true end return false end [/LUA] Untested, but it should work.[/QUOTE] I've noticed that it gives prediction issues on a listen server, when you run into a teammate, you would slow down for a short while before going through him. Didn't try it on a dedicated, but I thought I'd just point this out.
[QUOTE=_Kilburn;16810194]I've noticed that it gives prediction issues on a listen server, when you run into a teammate, you would slow down for a short while before going through him. Didn't try it on a dedicated, but I thought I'd just point this out.[/QUOTE] ShouldCollide is a shared hook (even though the wiki says otherwise), so you thus have to make your code using it shared as well.
[QUOTE=Jinto;16810310](even though the wiki says otherwise)[/QUOTE] Could always edit it. :3 Takes like 5 seconds, and helps others in the process.
Stop returning true for gods sake! If the condition is true (invert it), then return false. If the condition is false, don't return anything or you will most likely mess shit up for other addons using the hook and make me hate you.
[QUOTE=_Kilburn;16810194]I've noticed that it gives prediction issues on a listen server, when you run into a teammate, you would slow down for a short while before going through him. Didn't try it on a dedicated, but I thought I'd just point this out.[/QUOTE] Had that problem in my dedicated but since I was changing the size of the player's Hull I was sure it was the issue. Also, thanks Jinto, it'll be usefull to know it's shared.
[QUOTE=Sippeangelo;16814152]Stop returning true for gods sake! If the condition is true (invert it), then return false. If the condition is false, don't return anything or you will most likely mess shit up for other addons using the hook and make me hate you.[/QUOTE] That's only in hooks. The gamemode function is called last and should always return a value unless no value is required.
[QUOTE=Lexic;16821471]That's only in hooks. The gamemode function is called last and should always return a value unless no value is required.[/QUOTE] And therefore overriding all the hooks then, when we return true to everything but our silly condition.
Sorry, you need to Log In to post a reply to this thread.