Jump to content

disable killing between two expected teams


Deep thinker

Recommended Posts

hello, i am promax and i am scripting disable killing between two teams ( Military , Police ) ,i have tried to make it but i have failed 100% :3 ,i just knew the functions from an ex post ,but it wasn't useful that much but it was maded by Iprestege (Fahad) he helped me lil a bit ,also taught me some new functions

and i appreciate what he have done for me,

the script that he gave me 

--this was my first try to make these teams can't get killed.
local team = getTeamFromName (getLocalPlayer())
addEventHandler ( 'onClientPlayerDamage',root,
    function ()
    if ( team == "Unemployed" ) or ( team == "Off Duty Workers" ) or ( team == "Civilian" ) or ( team == "Emergency" ) then
            if getElementData ( Player, "team" )
                then
            cancelEvent()
                end
            end
        end
)           
----------------------------------------------------------------------------------------------------------------------
--that was Iprestege's one
addEventHandler ( 'onClientPlayerDamage',localPlayer,
    function ( aAttacker ) 
        if ( aAttacker and getElementType ( aAttacker ) == 'player' and aAttacker ~= source ) then
        local aLocalTeam = getPlayerTeam ( source )
        local aAttackerTeam = getPlayerTeam ( aAttacker )
        if ( aLocalTeam and aAttackerTeam ) then
        if ( aLocalTeam == getTeamFromName ( 'Unemployed' ) and aAttackerTeam == getTeamFromName ( 'Police' ) ) then
            cancelEvent (   )
            end
        end
    end
end
)

my question here ,how can i use table in Iprestege's one for the aAttackerTeam and aLocalTeam 

thank you :3

Link to comment
addEventHandler("onClientPlayerDamage", root,
    function()
       local team = getTeamName(getPlayerTeam(source))
	   if (team == "Unempolyed") or (team == "Off Duty Workers") or (team=="Emergency") then
	       if getElementData(source, "team") then
		      cancelEvent()
		   end
	   end
	end)
	
addEventHandler("onClientPlayerDamage", root,
    function(attacker)
	   if isElement(attacker) and getElementType(attacker) == "player" and attacker ~= source then
	      local aLocalTeam = getPlayerTeam(source)
		  local aAttackerTeam = getPlayerTeam(attacker)
		  if aLocalTeam and aAttackerTeam then
		     if aLocalTeam == getTeamFromName("Unempolyed") and aAttackerTeam == getTeamFromName("Police") then
			    cancelEvent()
			 end
		  end
	   end
	end)

 

Edited by Dimos7
Link to comment
2 minutes ago, Dimos7 said:
6 minutes ago, Dimos7 said:

if aLocalTeam == getTeamFromName("Unempolyed") and aAttackerTeam == getTeamFromName("Police") then

 

in the first part i have already   added the code which disabled death for (Unemployed , Civilian,Emergency ) then why did you disable death for him again.

also you didn't explain anything about what you have done.                                                                                           

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...