Jump to content

Anti Combat Logout


Recommended Posts

Posted

Hello!

I have a DayZ szerver, and i see some player has log out when other player shoot he. I would like to found a Anti Combat Logout system.

How i imagine this?

When the player get shoot, the system put he to Combat state. When the player logout in this, the system ban he to 1day. The combat state lasts 1 minute and not activate to hiting and falling.

Anybody can write this? Please help me and my server whit this resource. Thanks!

Posted
You mean like this?
addEventHandler("onPlayerLogout", getRootElement(), 
function() 
    if isPlayerDead(source) then 
    cancelEvent() 
    end 
end 
) 

Yes, when player logging out in combat, the script ban he for 1 day

Posted
Hello!

I have a DayZ szerver, and i see some player has log out when other player shoot he. I would like to found a Anti Combat Logout system.

How i imagine this?

When the player get shoot, the system put he to Combat state. When the player logout in this, the system ban he to 1day. The combat state lasts 1 minute and not activate to hiting and falling.

Anybody can write this? Please help me and my server whit this resource. Thanks!

I think I understand what you are looking for:

  
  
addEventHandler("onPlayerDamage", getRootElement(), 
function(attacker, weapon, body, loss) 
    if (attacker ~= source) then 
        local attackAccount = getPlayerAccount(attacker) 
        local sourceAccount = getPlayerAccount(source) 
         
        if not isGuestAccount(attackAccount) then 
            if not isGuestAccount(sourceAccount) then 
                setAccountData(attackAccount, "antideslog", false) 
                setTimer(function() 
                    for i, v in ipairs(getElementsByType("player"))do 
                        if v == attacker then 
                            setAccountData(attackAccount, "antideslog", true) 
                        end 
                    end 
                end, 60000, 1) 
            end 
            setAccountData(sourceAccount, "antideslog", false) 
            setTimer(function() 
                for i, v in ipairs(getElementsByType("player"))do 
                    if v == source then 
                        setAccountData(sourceAccount, "antideslog", true) 
                    end 
                end 
            end, 60000, 1) 
        end  
    end 
end) 
  
addEventHandler("onPlayerLogin", getRootElement(), 
function(previous, current, autologin) 
    if current then 
        local data = getAccountData(current, "antideslog") 
        if (data == true) then 
            -- ok, he can play 
        elseif(data == false)then 
            -- ban the player 
            setAccountData(current, "antideslog", true) 
            banPlayer(source) 
        else 
        end 
    end 
end) 

Posted
Hello!

I have a DayZ szerver, and i see some player has log out when other player shoot he. I would like to found a Anti Combat Logout system.

How i imagine this?

When the player get shoot, the system put he to Combat state. When the player logout in this, the system ban he to 1day. The combat state lasts 1 minute and not activate to hiting and falling.

Anybody can write this? Please help me and my server whit this resource. Thanks!

I think I understand what you are looking for:

  
  
addEventHandler("onPlayerDamage", getRootElement(), 
function(attacker, weapon, body, loss) 
    if (attacker ~= source) then 
        local attackAccount = getPlayerAccount(attacker) 
        local sourceAccount = getPlayerAccount(source) 
         
        if not isGuestAccount(attackAccount) then 
            if not isGuestAccount(sourceAccount) then 
                setAccountData(attackAccount, "antideslog", false) 
                setTimer(function() 
                    for i, v in ipairs(getElementsByType("player"))do 
                        if v == attacker then 
                            setAccountData(attackAccount, "antideslog", true) 
                        end 
                    end 
                end, 60000, 1) 
            end 
            setAccountData(sourceAccount, "antideslog", false) 
            setTimer(function() 
                for i, v in ipairs(getElementsByType("player"))do 
                    if v == source then 
                        setAccountData(sourceAccount, "antideslog", true) 
                    end 
                end 
            end, 60000, 1) 
        end  
    end 
end) 
  
addEventHandler("onPlayerLogin", getRootElement(), 
function(previous, current, autologin) 
    if current then 
        local data = getAccountData(current, "antideslog") 
        if (data == true) then 
            -- ok, he can play 
        elseif(data == false)then 
            -- ban the player 
            setAccountData(current, "antideslog", true) 
            banPlayer(source) 
        else 
        end 
    end 
end) 

Oh sorry, i can't scripting too good, and this code not working :(

you would do me, write messages, where put In combat, where put OUT combat and etc...

Posted

Oh sorry, i can't scripting too good, and this code not working :(

you would do me, write messages, where put In combat, where put OUT combat and etc...

Well, the script should work...

I put some comments in the code.

addEventHandler("onPlayerDamage", getRootElement(), 
function(attacker, weapon, body, loss) 
    if not (attacker == source) then 
        local attackAccount = getPlayerAccount(attacker) 
        local sourceAccount = getPlayerAccount(source) 
        
        if not isGuestAccount(sourceAccount) then 
            if not isGuestAccount(attackAccount) then 
                setAccountData(attackAccount, "antideslog", false) 
                setTimer(function() 
                    for i, v in ipairs(getElementsByType("player"))do -- check if the player still connected in the server 
                        if v == attacker then 
                            setAccountData(attackAccount, "antideslog", true) 
                            -- The attacker is not in combat anymore after 1 min 
                        end 
                    end 
                end, 60000, 1) 
            end 
             
            setAccountData(sourceAccount, "antideslog", false) 
            setTimer(function() 
                for i, v in ipairs(getElementsByType("player"))do -- check if the player still connected in the server 
                    if v == source then 
                        setAccountData(sourceAccount, "antideslog", true) 
                        -- The player who receive the shot is not in combat anymore after 1 min 
                    end 
                end 
            end, 60000, 1) 
        end 
         
        -- They are now in combat. 
    end 
end) 
  
addEventHandler("onPlayerLogin", getRootElement(), 
function(previous, current, autologin) 
    if current then 
        local data = getAccountData(current, "antideslog") 
        if (data == true) then 
            -- ok, he can play 
        elseif(data == false)then 
            -- ban the player 
            setAccountData(current, "antideslog", true) 
            banPlayer(source) 
        else 
        end 
    end 
end) 

Posted

Oh sorry, i can't scripting too good, and this code not working :(

you would do me, write messages, where put In combat, where put OUT combat and etc...

Well, the script should work...

I put some comments in the code.

addEventHandler("onPlayerDamage", getRootElement(), 
function(attacker, weapon, body, loss) 
    if not (attacker == source) then 
        local attackAccount = getPlayerAccount(attacker) 
        local sourceAccount = getPlayerAccount(source) 
        
        if not isGuestAccount(sourceAccount) then 
            if not isGuestAccount(attackAccount) then 
                setAccountData(attackAccount, "antideslog", false) 
                setTimer(function() 
                    for i, v in ipairs(getElementsByType("player"))do -- check if the player still connected in the server 
                        if v == attacker then 
                            setAccountData(attackAccount, "antideslog", true) 
                            -- The attacker is not in combat anymore after 1 min 
                        end 
                    end 
                end, 60000, 1) 
            end 
             
            setAccountData(sourceAccount, "antideslog", false) 
            setTimer(function() 
                for i, v in ipairs(getElementsByType("player"))do -- check if the player still connected in the server 
                    if v == source then 
                        setAccountData(sourceAccount, "antideslog", true) 
                        -- The player who receive the shot is not in combat anymore after 1 min 
                    end 
                end 
            end, 60000, 1) 
        end 
         
        -- They are now in combat. 
    end 
end) 
  
addEventHandler("onPlayerLogin", getRootElement(), 
function(previous, current, autologin) 
    if current then 
        local data = getAccountData(current, "antideslog") 
        if (data == true) then 
            -- ok, he can play 
        elseif(data == false)then 
            -- ban the player 
            setAccountData(current, "antideslog", true) 
            banPlayer(source) 
        else 
        end 
    end 
end) 

Many thanks!

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