Jacobob14 Posted May 19, 2014 Posted May 19, 2014 because the script leaves me working after a while function protect() for i, TEAMS in ipairs ( getElementsByType("team") ) do if ( getTeamFriendlyFire ( TEAMS ) == true ) then setTeamFriendlyFire ( TEAMS, false ) end end end addEventHandler("onResourceStart", resourceRoot, protect)
Jacobob14 Posted May 19, 2014 Author Posted May 19, 2014 What? everything works fine but after a time the script stops working and teams can kill
MIKI785 Posted May 19, 2014 Posted May 19, 2014 The script gets executed just on the resource's start. Use other event or use a timer.
LonelyRoad Posted May 19, 2014 Posted May 19, 2014 Are you adding/removing teams after the resource start? This works fine, but only on teams that exist at resource start.
TAPL Posted May 19, 2014 Posted May 19, 2014 You may have another script that enable the friendly fire again or as LonelyRoad said above.
iPrestege Posted May 19, 2014 Posted May 19, 2014 addEventHandler ("onClientPlayerDamage",root, function ( attacker ) local attackerTeam = getPlayerTeam ( attacker ) local sourceTeam = getPlayerTeam ( source ) if ( attackerTeam == sourceTeam ) then cancelEvent ( ) end end ) P.S . It should be in the client side don't forget that.
TAPL Posted May 19, 2014 Posted May 19, 2014 You miss the fact that the attacker may not exist or exist but not player or the attacker is the same person who got the damage.
AboShanab Posted May 19, 2014 Posted May 19, 2014 addEventHandler ("onClientPlayerDamage",root, function ( attacker ) if ( attacker and getElementType ( attacker ) == "player" ) then if ( attacker ~= source ) then local attackerTeam = getPlayerTeam ( attacker ) local sourceTeam = getPlayerTeam ( source ) if ( attackerTeam == sourceTeam ) then cancelEvent () end end end end )
iPrestege Posted May 19, 2014 Posted May 19, 2014 You miss the fact that the attacker may not exist or exist but not player or the attacker is the same person who got the damage. Ops! Sorry I wrote that from my iPhone.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now