Jump to content

Different teams anti teamkill?


Bean666

Recommended Posts

hi , is it possible for 2 different teams will not be able to kill each other?

example : SWAT and Army are 2 different teams. is it possible that they will not be able to kill each other while they are on a different team.

yes it's , just check player team onClientPlayerDamage ()

example:

addEventHandler("onClientPlayerDamage", localPlayer, 
function(attacker) 
if (attacker and getElementType(attacker) == "player" and attacker ~= source) then 
    if (getTeamName(getPlayerTeam(attacker)) == "SWAT") and (getTeamName(getPlayerTeam(source)) == "Army") then  
     cancelEvent() 
   end  
 end 
end  
) 

Edited by Guest
Link to comment

try this

local flist = { ["SWAT"] = "Army", ["Army"] = "SWAT" } 
addEventHandler("onClientPlayerDamage", localPlayer, 
    function(attacker) 
        if attacker and getElementType(attacker) == "player" then 
            local sTeam = getPlayerTeam(localPlayer) --------- swat team 
            local aTeam = getPlayerTeam(attacker) --------- army team 
            if aTeam and sTeam and flist[getTeamName(sTeam)] == getTeamName(aTeam) then 
                cancelEvent() 
            end 
        end 
    end 
) 

but there is one problem both the team will still be able to kill with knife.

you can use

onClientPlayerStealthKill 

to fix it.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...