Jump to content

[HELP]How to put god mode in team ?


Black2

Recommended Posts

Posted
addEventHandler("onClientPlayerDamage", localPlayer, 
function() 
if getPlayerTeam(localPlayer) and getTeamName == "Team Name" then 
cancelEvent() 
else return false 
end 
end 
) 

Untested.

Posted

Client side

godModeTeams = { 
    ["Name"] = true, 
} 
  
addEventHandler ( "onClientPlayerDamage", localPlayer, 
    function ( ) 
        local team = getPlayerTeam ( source ) 
        if ( team and godModeTeams [ getTeamName ( team ) ] ) then 
            cancelEvent ( ) 
        end 
    end 
) 

Posted (edited)
addEventHandler("onClientPlayerDamage", localPlayer, 
function() 
if getPlayerTeam(localPlayer) and getTeamName == "Team Name" then 
cancelEvent() 
else return false 
end 
end 
) 

Untested.

Where is the element?

Anyway, try this

  
function Ebc ( attacker, weapon, bodypart ) 
    local pt = getPlayerTeam(source) 
        if (pt) then 
            if getTeamName(pt) == "Team name" then 
                cancelEvent() 
            end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), Ebc ) 
  

Not tested

Edited by Guest
Posted (edited)

Something like this?

function friendlyFire() 
local team = getPlayerTeam(source) 
if team then 
if getTeamName(source) == "Team Name" then 
setTeamFriendlyFire(source, true) 
else return false 
end 
end 
end 
addEventHandler("onResourceStart", root, friendlyFire) 

Untested.

Edited by Guest
Posted (edited)
Something like this?
function friendlyFire() 
local team = getPlayerTeam() 
if team then 
if getTeamName(source) == "Team Name" then 
setTeamFriendlyFire(team, false) --Don't know if it should be 'source' or 'team' 
else return false 
end 
end 
end 
addEventHandler("onResourceStart", root, friendlyFire) 

Untested.

setTeamFriendlyFire(team, true) -- edited

Edited by Guest
Posted

I would just suggest to use this

  
function Ebc ( attacker, weapon, bodypart ) 
    local pt = getPlayerTeam(source) 
        if (pt) then 
            if getTeamName(pt) == "Team name" then 
                cancelEvent() 
            end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), Ebc ) 
  

Posted
I would just suggest to use this

  
function Ebc ( attacker, weapon, bodypart ) 
    local pt = getPlayerTeam(source) 
        if (pt) then 
            if getTeamName(pt) == "Team name" then 
                cancelEvent() 
            end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), Ebc ) 
  

Simply no!

addEventHandler('onResourceStart',resourceRoot, 
   function () 
     setTeamFriendlyFire(getTeamFromName('NAME'),false) 
end) 

Posted
I would just suggest to use this

  
function Ebc ( attacker, weapon, bodypart ) 
    local pt = getPlayerTeam(source) 
        if (pt) then 
            if getTeamName(pt) == "Team name" then 
                cancelEvent() 
            end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), Ebc ) 
  

Simply no!

addEventHandler('onResourceStart',resourceRoot, 
   function () 
     setTeamFriendlyFire(getTeamFromName('NAME'),false) 
end) 

Has i said before it will not cancel the damage coming from fire.

  • Moderators
Posted

Damage from fire is most of the time not bounded to an attacker or the attacker weapon is unknown. Cancel using cancelEvent() would be hard under those conditions. The result will be in the end the same, it doesn't matter who owns the fire you simply die...

So setTeamFriendlyFire would give the most performance.

If you don't want fire in your server:

addEventHandler("onClientPreRender",root, 
function () 
    if isPedOnFire(localPlayer) then 
        setPedOnFire(localPlayer,false) 
    end 
end) 

Posted
Damage from fire is most of the time not bounded to an attacker or the attacker weapon is unknown. Cancel using cancelEvent() would be hard under those conditions. The result will be in the end the same, it doesn't matter who owns the fire you simply die...

So setTeamFriendlyFire would give the most performance.

If you don't want fire in your server:

addEventHandler("onClientPreRender",root, 
function () 
    if isPedOnFire(localPlayer) then 
        setPedOnFire(localPlayer,false) 
    end 
end) 

This will cancel the damage from fire, You should test it.

function Ebc ( attacker, weapon, bodypart ) 
    local pt = getPlayerTeam(source) 
        if (pt) then 
            if getTeamName(pt) == "Team name" then 
                cancelEvent() 
            end 
end 
addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), Ebc ) 

  • Moderators
Posted

That will dissable all damage, if he wants it that way then yes.

But what I am trying to tell you is that you never know when the damage is caused by the fire.

Posted

The reason why i'm not suggesting him to use setteamfriendyfire function is because it has the following bugs

-attacker can still kill with fire weapons

-attacker can still kill with knife

-attackera can still kill with vehicles

And his question was how to set god mode to a team

So i suggested him to use onClientPlayerDamage

Even onClientPlayerDamage has a bug it still also allows attacker to kill with knife

But it can easily be fixed by using the function onClientSteathKill.

Posted

To prevent knife kill, he can use.

addEventHandler("onClientStealthKill", localPlayer, 
function() 
local team = getPlayerTeam(localPlayer) 
if not team then 
return false 
end 
local teamname = getTeamFromName("Team Name") 
if teamname then 
cancelEvent() 
else 
return false 
end 
end 
) 

Untested.

Posted
To prevent knife kill, he can use.
addEventHandler("onClientStealthKill", localPlayer, 
function() 
local team = getPlayerTeam(localPlayer) 
if not team then 
return false 
end 
local teamname = getTeamFromName("Team Name") 
if teamname then 
cancelEvent() 
else 
return false 
end 
end 
) 

Untested.

Very bad scripted, this will check does the team exists and not if the player is in team

It should be like this, didn't tested it though

addEventHandler('onPlayerStealthKill',root, 
   function (targetPlayer) 
   team = getPlayerTeam(source) 
   if team then 
   if team ~= getPlayerTeam(targetPlayer) 
   cancelEvent() 
 end 
end) 

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