Jump to content

onPlayerDamage problem


Castillo

Recommended Posts

hey, i want to make when a player is on same team and he tryes to kill his teamate the health won't go down, i've done something but it won't work.

function playerDamage ( attacker, weapon, bodypart, loss ) 
if attacker then 
if getElementType ( attacker ) == "vehicle" then cancelEvent() 
else 
local team = getPlayerTeam(source) 
local teamname = getTeamName(team) 
local team2 = getPlayerTeam(attacker) 
local teamname2 = getTeamName(team2) 
if teamname == teamname2 then 
--triggerClientEvent(source,"enableGodMode",source) 
        cancelEvent() 
            end 
        end 
    end 
end 
addEventHandler ( "onPlayerDamage", getRootElement(), playerDamage) 

thanks in advance.

addEvent("enableGodMode", true) 
addEventHandler ("enableGodMode", getRootElement(),  
function() 
  addEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent) 
end) 

Link to comment
  varez said:

that was my old idea but dunno why it won't work O_o

code was:

addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
function () 
local allTeams = getElementsByType ( "team" ) 
for index, theTeam in ipairs(allTeams) do 
    if ( getTeamFriendlyFire ( theTeam ) == true ) then 
        setTeamFriendlyFire ( theTeam, false ) 
              end 
    end 
end) 

Link to comment
  varez said:
hmm, what i don't like in games is that, that some of them treats friendly fire as when it's OFF - you can't kill your team mate, and some when it's ON.

Try to reverse it, and set to true.

And remove that "if" - you think it's really needed?

Ok, when i will try when i get someone else.

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