Anti Team kill Script darkrp

Hello, I’m making a modified Team Death match from darkrp gamemode, ive been trying to set teams from not killing each other and can not find any script.

Something like

TEAM_ONE cant kill TEAM_ONE

             and

TEAM_TWO cant kill TEAM_TWO

But TEAM_ONE can kill TEAM_TWO and TEAM_TWO can kill TEAM_ONE

I tried Ace cools Anti Teamkill https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/anti_teamkill_system.lua.html doesn’t seem to work if you could help me it would be very helpful thanks.

The link you posted doesn’t work.

Sorry should work now

That code looks fine. Make sure that you are modifying the table to match your team structure.



local ANTI_TEAMKILL_TEAMS_TABLE = {
    // Team 1
    TEAM_ONE    = 1;
    TEAM_TWO    = 1;
    TEAM_THREE  = 1;

    // Team 2
    TEAM_FOUR   = 2;
    TEAM_FIVE   = 2;
    TEAM_SIX    = 2;
};


Yeah, you changed these to what the DarkRP teams are called right

local ANTI_TEAMKILL_TEAMS_TABLE = {
// Team 1
TEAM_COP = 1;

// Team 2
TEAM_ROBBER = 2;

};

Iv put something like this please correct me if this is wrong

Also when i use his code both teams can not kill each other and cannot team kill each other

Add return true above the last end.

what why

@op please post your team tables here.

http://forum.facepunch.com/showthread.php?t=1389361&p=44666822&viewfull=1#post44666822

He already did?

Here’s the thing; you’re right, it may not work.

The reason it may not work, is because it’s using a string TEAM_ONE, TEAM_TWO, etc to make the comparison. You need the ID of the team for it to work…

So, you do [ TEAM_ONE ] = 1; [ TEAM_TWO ] = 1; etc…

That’ll parse it as a number instead of a string.

To recap, add brackets around each team, keep the numbers identical of which teams should be friendly.

[editline]28th April 2014[/editline]

Note: Added this to the text:

[lua]//
// Configuration Table - Make sure the teams you want immunity between share the same number
//
local ANTI_TEAMKILL_TEAMS_TABLE = {
// Please note, your team system may require an ID to compare instead of a string name
// as depicted below; If you use string identifiers, or string identifiers are returned
// when you print( Entity( 1 ):Team( ) ), you’d put those identifiers below. IF they are
// referenced as numerical ids, you may need to parse the identifiers by wrapping them in
// square-brackets ( ).
//
// PARSED AS NUMERICAL KEY EXAMPLE ( Rest of the script will work as is ):

// Team 1
-- [ TEAM_ONE ] 	= 1;
-- [ TEAM_TWO ] 	= 1;
-- [ TEAM_THREE ] 	= 1;

// Team 2
-- [ TEAM_FOUR ] 	= 2;
-- [ TEAM_FIVE ] 	= 2;
-- [ TEAM_SIX ] 	= 2;

// Team 1
TEAM_ONE 	= 1;
TEAM_TWO 	= 1;
TEAM_THREE 	= 1;

// Team 2
TEAM_FOUR 	= 2;
TEAM_FIVE 	= 2;
TEAM_SIX 	= 2;

};[/lua]

https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/anti_teamkill_system.lua.html

DarkRP Team identifiers return the number instead of returning a string.

What do you mean as a team id? can you show me an example? if as you have jobs on darkrp

Run this on your server after everything has loaded;
[lua]concommand.Add( “dev_printteams”, function( _p, _cmd, _args )
print( "COP TEAM: " … TEAM_COP );
print( "ROBBER TEAM: " … TEAM_ROBBER );
end );[/lua]

Put it in addons/acecool/lua/autorun/dev_printteams.lua

Type it once in console on the client, and do the same in your srcds console window. It should print:

[lua]COP TEAM: 1
ROBBER TEAM: 2[/lua]

Or something similar. So, when you put it in the table just as TEAM_COP, then it is exactly the same as typing Player:Team( ) == “TEAM_COP” instead of Player:Team( ) == 1

So, without the square brackets, the text isn’t being parsed, you need it to be parsed so the ID can be used.

So this would be along the lines of what you need to run to get it to work:
[lua]//
// Configuration Table - Make sure the teams you want immunity between share the same number
//
local ANTI_TEAMKILL_TEAMS_TABLE = {
// Team 1
[ TEAM_COP ] = 1;
[ TEAM_SWAT ] = 1;
– [ TEAM_THREE ] = 1;

// Team 2
[ TEAM_ROBBER ] 	= 2;
-- [ TEAM_FIVE ] 	= 2;
-- [ TEAM_SIX ] 	= 2;

};[/lua]

It’ll parse the TEAM_COP and TEAM_ROBBER; I added TEAM_SWAT as a secondary friendly to the first team, so it parses them to the number. So if you PrintTable( ANTI_TEAMKILL_TEAMS_TABLE );

It’ll print something like:

[lua]1 = 1
2 = 1
3 = 2[/lua]

1 = 1 means TEAM_COP = 1
2 = 1 means TEAM_SWAT = 1
3 = 2 means TEAM_ROBBER = 2

The rest of the script will properly compare the rest; your ids may not match the example numbers. Try it out though and report back!

this isnt working please help