Jump to content

onPlayerDamage problem


Castillo

Recommended Posts

Posted

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) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

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) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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?

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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