• team killing, custom gamemode
    12 replies, posted
hi, im wondering why this code isnt working [CODE]function GM:PlayerShouldTakeDamage( ply, att ) if ply:Team() == att:Team then return false att:PrintMessage( ply:Nick() .. " Is On Your Team!" ) att:PrintMessage( "Stop Shooting!" ) end end)[/CODE] for my no team kill script, and if anyone could help me make one? i was given this one by .Author but it doesnt work and doesnt let team 0 kill team 1 [CODE]function GM:PlayerShouldTakeDamage( victim, killer ) if victim:Team() == killer:Team() then return false end end[/CODE]
[code] function GM:PlayerShouldTakeDamage( victim, killer ) if victim:Team() == killer:Team() then return false end return true end [/code] Try that.
[QUOTE=Pawsative;47297776][code] function GM:PlayerShouldTakeDamage( victim, killer ) if victim:Team() == killer:Team() then return false end return true end [/code] Try that.[/QUOTE] That shouldn't change anything as it's basically set to do true if nothing is returned. Do you get no errors at script startup or when it's run? Are the teams set?
1. Make sure that you are running it server side. 2. Try and print the teams, see if they are actually the same. Basically just debug it..
[QUOTE=TheCodingBoss;47296383]hi, im wondering why this code isnt working [CODE]function GM:PlayerShouldTakeDamage( ply, att ) if ply:Team() == att:Team then return false att:PrintMessage( ply:Nick() .. " Is On Your Team!" ) att:PrintMessage( "Stop Shooting!" ) end end)[/CODE] for my no team kill script, and if anyone could help me make one? i was given this one by .Author but it doesnt work and doesnt let team 0 kill team 1 [CODE]function GM:PlayerShouldTakeDamage( victim, killer ) if victim:Team() == killer:Team() then return false end end[/CODE][/QUOTE] That looks like it should work. Are you sure that the players are actually being set to the same team?
[QUOTE=GoldTrigger;47300171]That looks like it should work. Are you sure that the players are actually being set to the same team?[/QUOTE] except the message to the player won't be printed. Code is fine, the coding boss just doesn't know what he's doing and has integrated it wrong. If only there were some kind of boss of the codes to help him.
Acecool helped me with this one. [lua] ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; hook.Add( "InitPostEntity", "ParseTableAtRightTime", function( ) ANTI_TEAMKILL_TEAMS_TABLE = { [ TEAM_1 ] = 1; --Team 2 [ TEAM_2 ] = 2; }; end ); hook.Add("PlayerShouldTakeDamage", "PlayerShouldTakeDamage:AvoidTeamDamage", function( _victim, _attacker ) if ( IsValid( _victim ) && IsValid( _attacker ) && _victim:IsPlayer( ) && _attacker:IsPlayer( ) ) then if (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 1 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 1) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 2 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 2) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 7 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 7) then return true; else if ( ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] ) then return false; end end end end ); [/lua] This will prevent team damage all together.
[QUOTE=Subject_Alpha;47302473]Acecool helped me with this one. [lua] ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; hook.Add( "InitPostEntity", "ParseTableAtRightTime", function( ) ANTI_TEAMKILL_TEAMS_TABLE = { [ TEAM_1 ] = 1; --Team 2 [ TEAM_2 ] = 2; }; end ); hook.Add("PlayerShouldTakeDamage", "PlayerShouldTakeDamage:AvoidTeamDamage", function( _victim, _attacker ) if ( IsValid( _victim ) && IsValid( _attacker ) && _victim:IsPlayer( ) && _attacker:IsPlayer( ) ) then if (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 1 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 1) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 2 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 2) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 7 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 7) then return true; else if ( ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] ) then return false; end end end end ); [/lua] This will prevent team damage all together.[/QUOTE] thanks man your a life saver!
Here's a newer version of that script: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/simple_anti_teamkill_system/anti_teamkill_system_with_failsafe.lua.html[/url] [ NOTE ] Remove .html to view / copy .Lua ...
[QUOTE=Subject_Alpha;47302473]Acecool helped me with this one. [lua] ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; hook.Add( "InitPostEntity", "ParseTableAtRightTime", function( ) ANTI_TEAMKILL_TEAMS_TABLE = { [ TEAM_1 ] = 1; --Team 2 [ TEAM_2 ] = 2; }; end ); hook.Add("PlayerShouldTakeDamage", "PlayerShouldTakeDamage:AvoidTeamDamage", function( _victim, _attacker ) if ( IsValid( _victim ) && IsValid( _attacker ) && _victim:IsPlayer( ) && _attacker:IsPlayer( ) ) then if (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 1 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 1) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 2 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 2) then return true; elseif (ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == 7 && ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] == 7) then return true; else if ( ANTI_TEAMKILL_TEAMS_TABLE[ _victim:Team( ) ] == ANTI_TEAMKILL_TEAMS_TABLE[ _attacker:Team( ) ] ) then return false; end end end end ); [/lua] This will prevent team damage all together.[/QUOTE] my eyes literally bleed trying to read this
Why are you making it so advanced? Friendly fire can be disabled just like this as well. [lua]hook.Add("PlayerShouldTakeDamage", "Anti-FF", function( victim, attacker ) if IsValid( attacker ) and attacker:IsPlayer() and IsValid( victim ) then if ( victim:Team() == attacker:Team() ) then -- attacker:ChatPrint("Don't fire at your own team.") return false end end end)[/lua] Sorry for tabbing wrote on my phone.
Mine allows you to set TEAM_POLICE, TEAM_POLICE_CHIEF, etc.. as common ids, ie group teams together. The one you posted means that common "teams" will not be considered "friendly"... I'm not a fan of how many people use the team system to create many "teams" instead of creating a simple role system, but because it is how almost everyone handles teams ( Even TTT has 3 teams, Detective, Terrorist, and Good Guy Traitors; where Terrorist and Detective would be able to damage each other using the code you posted [ even though they're considered "Roles", they still use the team system ] )... I'm rewriting the entire team module which will build all of this in with options for all of it, plus rewrite how spawn systems will work.. It'll be, for the most part, stand-alone ( Except it uses one of my custom hooks for when it should create the team assignments [ called after CreateTeams ] which is easy enough to change ) for those that want to use the features: [url]https://trello.com/c/wZC63qO5/1-team-module-extension[/url]
He never mentioned anything with different teams that work together, etc? From the latest threads the OP has made, it looks like he is trying to create a team death match gamemode themed off of Advanced Warfare from scratch, which I am very certain don't need anything related to roles or different teams that would be friendly together.
Sorry, you need to Log In to post a reply to this thread.