Jump to content

[HELP] Friendly Fire


CJGrove

Recommended Posts

Hello all,

I tried something like this but it doesn't kill the player can someone help me with this?

Thanks in advance :)

function setFriendlyFireOn ( )      
        for index, theTeam in ipairs ( getElementsByType("team") ) do 
                if ( getTeamFriendlyFire ( theTeam ) == false ) then 
                        setTeamFriendlyFire ( theTeam, true ) 
                        outputChatBox ( "Friendly fire turned ON", 255, 0, 0 ) 
                        outputDebugString ( "Friendly fire turned ON", 3 ) 
                        else 
                        setTeamFriendlyFire ( theTeam, false ) 
                        outputChatBox ( "Friendly fire turned OFF", 0, 255, 0 ) 
                        outputDebugString ( "Friendly fire turned OFF", 3 ) 
                end 
        end 
end 
  
function friendlyfire ( theTeam, ammo, killer, killerweapon, bodypart ) 
   for index, theTeam in ipairs ( getElementsByType("team") ) do 
     if ( getTeamFriendlyFire ( theTeam ) == false ) then 
       if ( killer ) and ( killer ~= source ) then  
         kill = killPlayer ( killer ) 
         if ( kill ) then 
          outputChatBox ( "FRIENDLY FIRE BY " .. killer .. "! He has been killed.", 255, 0, 0 ) 
          else 
          outputDebugString ( "Player hasn't been killed", 3 ) 
         end 
        else 
        outputDebugString ( "Source is killer", 3 ) 
       end 
     end 
   end 
end 
  
function getff ( ) 
  for index, theTeam in ipairs ( getElementsByType("team") ) do 
    if ( getTeamFriendlyFire ( theTeam ) == false ) then 
    outputChatBox ( "Friendly fire turned off. You will be killed when you kill your teammate.", source ) 
    else 
    outputChatBox ( "Friendly fire turned on. You can kill your teammate.", source ) 
    end 
  end 
end 
  
addCommandHandler ( "getff", getff ) 
addCommandHandler ( "setff", setFriendlyFireOn ) 
addEventHandler ( "onPlayerWasted", getRootElement(), friendlyfire ) 

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