• Anti Teamkill
    20 replies, posted
So, I got some code for anti-teamkill for my MilitaryRP server. What this does is basically doesn't let anyone kill anyone. I don't know what is wrong. [code]ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; hook.Add( "InitPostEntity", "ParseTableAtRightTime", function( ) ANTI_TEAMKILL_TEAMS_TABLE = { [ TEAM_CITIZEN ] = 1; [ TEAM_SCAVENGER ] = 2; -- Team 1 [ TEAM_USMC1 ] = 3; [ TEAM_USMC2 ] = 3; [ TEAM_USMC3 ] = 3; [ TEAM_USMC4 ] = 3; [ TEAM_USMC5 ] = 3; [ TEAM_USMC6 ] = 3; [ TEAM_USMC7 ] = 3; [ TEAM_USMC8 ] = 3; [ TEAM_USMC9 ] = 3; [ TEAM_USMC10 ] = 3; [ TEAM_USMC11 ] = 3; [ TEAM_USMC12 ] = 3; [ TEAM_USMC13 ] = 3; -- Team 2 [ TEAM_CUBAN1 ] = 4; [ TEAM_CUBAN2 ] = 4; [ TEAM_CUBAN3 ] = 4; [ TEAM_CUBAN4 ] = 4; [ TEAM_CUBAN5 ] = 4; [ TEAM_CUBAN6 ] = 4; [ TEAM_CUBAN7 ] = 4; [ TEAM_CUBAN8 ] = 4; [ TEAM_CUBAN9 ] = 4; [ TEAM_CUBAN10 ] = 4; [ TEAM_CUBAN11 ] = 4; [ TEAM_CUBAN12 ] = 4; [ TEAM_CUBAN13 ] = 4; -- Team 3 [ TEAM_RUSSIAN1 ] = 5; [ TEAM_RUSSIAN2 ] = 5; [ TEAM_RUSSIAN3 ] = 5; [ TEAM_RUSSIAN4 ] = 5; [ TEAM_RUSSIAN5 ] = 5; [ TEAM_RUSSIAN6 ] = 5; [ TEAM_RUSSIAN7 ] = 5; [ TEAM_RUSSIAN8 ] = 5; [ TEAM_RUSSIAN9 ] = 5; [ TEAM_RUSSIAN10 ] = 5; [ TEAM_RUSSIAN11 ] = 5; [ TEAM_RUSSIAN12 ] = 5; [ TEAM_RUSSIAN13 ] = 5; -- Team 4 [ TEAM_GERMAN1 ] = 6; [ TEAM_GERMAN2 ] = 6; [ TEAM_GERMAN3 ] = 6; [ TEAM_GERMAN4 ] = 6; [ TEAM_GERMAN5 ] = 6; [ TEAM_GERMAN6 ] = 6; [ TEAM_GERMAN7 ] = 6; [ TEAM_GERMAN8 ] = 6; [ TEAM_GERMAN9 ] = 6; [ TEAM_GERMAN10 ] = 6; [ TEAM_GERMAN11 ] = 6; [ TEAM_GERMAN12 ] = 6; [ TEAM_GERMAN13 ] = 6; -- Team 5 [ TEAM_MERC1 ] = 7; [ TEAM_MERC2 ] = 7; [ TEAM_MERC3 ] = 7; [ TEAM_MERC4 ] = 7; [ TEAM_MERC5 ] = 7; [ TEAM_MERC6 ] = 7; [ TEAM_MERC7 ] = 7; [ TEAM_MERC8 ] = 7; [ TEAM_MERC9 ] = 7; [ TEAM_MERC10 ] = 7; [ TEAM_MERC11 ] = 7; -- Team 6 [ TEAM_BSAS1 ] = 8; [ TEAM_BSAS2 ] = 8; [ TEAM_BSAS3 ] = 8; [ TEAM_BSAS4 ] = 8; [ TEAM_BSAS5 ] = 8; [ TEAM_BSAS6 ] = 8; [ TEAM_BSAS7 ] = 8; [ TEAM_BSAS8 ] = 8; [ TEAM_BSAS9 ] = 8; [ TEAM_BSAS10 ] = 8; [ TEAM_BSAS11 ] = 8; [ TEAM_BSAS12 ] = 8; [ TEAM_BSAS13 ] = 8; }; 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 ); [/code] This is not my code, I got it from a GitHub download. Also if it is unclear, I want it so the countries can't kill their team, but civis, scavs, and mercs can kill eachother
First off: string.Left
what the fuck, why is there so many teams
[QUOTE=NiandraLades;50547048]what the fuck, why is there so many teams[/QUOTE] I think they're all DarkRP jobs.
[QUOTE=VeXan;50547453]I think they're all DarkRP jobs.[/QUOTE] Yes but that's still a lot of teams, nonetheless.
[QUOTE=LittleBigBug;50547508]Yes but that's still a lot of teams, nonetheless.[/QUOTE] It's just the ranks going through the countries. Each country has 13 ranks, and then all the countries. It just adds up to a lot of teams. Can we get back to problem at hand? Thanks :)
This is stupid. I don't know who did this but this is stupid. [CODE] ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; [/CODE] That table shouldn't already exist [CODE] ANTI_TEAMKILL_TEAMS_TABLE = { }; [/CODE]
[QUOTE=Potatofactory;50549194]This is stupid. I don't know who did this but this is stupid. [CODE] ANTI_TEAMKILL_TEAMS_TABLE = ANTI_TEAMKILL_TEAMS_TABLE || { }; [/CODE] That table shouldn't already exist [CODE] ANTI_TEAMKILL_TEAMS_TABLE = { }; [/CODE][/QUOTE] no it's for autorefresh
Bump?
[QUOTE=JaguarHDX;50549173]It's just the ranks going through the countries. Each country has 13 ranks, and then all the countries. It just adds up to a lot of teams. Can we get back to problem at hand? Thanks :)[/QUOTE] Unless it's absolutely needed this sounds quite sloppy - can you have one team for each country and assign a variable to each player that holds rank?
-snip-
[QUOTE=NiandraLades;50556147]Unless it's absolutely needed this sounds quite sloppy - can you have one team for each country and assign a variable to each player that holds rank?[/QUOTE] I could but that's not how I decided to do it. Now please, I need this fixed. I know I have lots of teams but that's how I want it :)
Add prints to see whats wrong with it? Not to sound mean but have you tried to fix it yourself?
[QUOTE=JaguarHDX;50556418]I could but that's not how I decided to do it. Now please, I need this fixed. I know I have lots of teams but that's how I want it :)[/QUOTE] The way you decided to do it is really, really dumb
[QUOTE=Tupac;50557249]The way you decided to do it is really, really dumb[/QUOTE] Especially since every rank within that team structure seems to be the same number/enumeration
[QUOTE=SteppuFIN;50556623]Add prints to see whats wrong with it? Not to sound mean but have you tried to fix it yourself?[/QUOTE] I can't find the problem. That's why I came here.
[QUOTE=JaguarHDX;50557560]I can't find the problem. That's why I came here.[/QUOTE] You didn't answer the question. Did you add prints to try and figure out what is wrong? Additionally is the code giving off any errors?
[QUOTE=boxvader;50558771]You didn't answer the question. Did you add prints to try and figure out what is wrong? Additionally is the code giving off any errors?[/QUOTE] I don't know what you mean by prints and no, the code gives off absolutely no errors.
[QUOTE=JaguarHDX;50560491]I don't know what you mean by prints and no, the code gives off absolutely no errors.[/QUOTE] Have you even tried googling what is PRINT... Add in your code to different parts [CODE] print("part ... passed") [/CODE] so you could see where the code stops and see whats wrong. No one is going to spoonfeed/help you if you dont even try.
Huh... I should probably update that part of my GitHub so everything works. Also, if you're using that, you need to have every job you have created added to the table. Acecool made that anti teamkill. Here's the updated version. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/anti_teamkill_system.lua[/url] Good luck, Illusion.
[QUOTE=Subject_Alpha;50560896]Huh... I should probably update that part of my GitHub so everything works. Also, if you're using that, you need to have every job you have created added to the table. Acecool made that anti teamkill. Here's the updated version. [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/anti_teamkill_system.lua[/url] Good luck, Illusion.[/QUOTE] Thanks.
Sorry, you need to Log In to post a reply to this thread.