Jump to content

Simple request about onPlayerNetworkStatus


Recommended Posts

Posted

Hi ,

i want if player connection interrupt , it is kicked

also type in chat that the player was kicked because it's connection is interrupt

Here the Server Side code :

-- Server Side 
  
addEventHandler( "onPlayerNetworkStatus", root, 
  function( status, ticks ) 
    if status == 0 then 
      outputDebugString( "(packets from " .. getPlayerName(source) .. ") interruption began " .. ticks .. " ticks ago" ) 
    elseif status == 1 then 
      outputDebugString( "(packets from " .. getPlayerName(source) .. ") interruption began " .. ticks .. " ticks ago and has just ended" ) 
    end 
  end 
) 

Client Side code :

-- Client Side 
  
frozen = false -- This variable stores whether or not the script is going to freeze them. 
-- If they were already frozen then don't unfreeze them when the interruption ends to avoid conflicts with other scripts. 
function handleInterrupt( status, ticks ) 
    if (status == 0) then 
        outputDebugString( "(packets from server) interruption began " .. ticks .. " ticks ago" ) 
        if (not isElementFrozen(localPlayer)) then 
            setElementFrozen(localPlayer, true) -- Freeze them to prevent them abusing the network interruption 
            frozen = true 
        end 
    elseif (status == 1) then 
        outputDebugString( "(packets from server) interruption began " .. ticks .. " ticks ago and has just ended" ) 
        if (frozen) then 
            setElementFrozen(localPlayer, false) -- If we froze them, unfreeze them now. 
            frozen = false 
        end 
    end 
end 
addEventHandler( "onClientPlayerNetworkStatus", root, handleInterrupt) 

Posted

-- Server Side

    addEventHandler( "onPlayerNetworkStatus", root, 
      function( status, ticks ) 
        if status == 0 then 
          kickPlayer(source,"Your network has frozen") 
        end 
      end 
    ) 

You can remove client.

Posted
-- Server Side
    addEventHandler( "onPlayerNetworkStatus", root, 
      function( status, ticks ) 
        if status == 0 then 
          kickPlayer(source,"Your network has frozen") 
        end 
      end 
    ) 

You can remove client.

client side is useless ? , and why ?

Posted

Well really client side was useless in the first place in my own opinion. All it does it tell the debugscript client side and freeze / unfreeze the player. All could be done server side.

Posted
Well really client side was useless in the first place in my own opinion. All it does it tell the debugscript client side and freeze / unfreeze the player. All could be done server side.

Thank you man.

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