Jump to content

PingKicker


Recommended Posts

Hello guys i need help, i got this script but i want that i dont need to typ /ping but it checks it automaticly and when it gets over the maximum ping you get kicked

Serverping.lua

function checkPing() 
    local ping = getPlayerPing(source)    -- get the ping from the source element (the player who joined) 
    if (ping > 100) then                  -- if it's higher than 100... 
        outputChatBox("Your ping is pretty high! Please try to lower it if possible.", source) -- output a message to the player 
    end 
end 
addEventHandler("onPlayerJoin", getRootElement(), checkPing) -- add the event handler 

clientping.lua

function checkPing() 
        local ping = getPlayerPing(getLocalPlayer())  -- get the ping from the source element (the player who joined) 
        if (ping > 100) then                          -- if it's higher than 100... 
                outputChatBox("Your ping is pretty high! Please try to lower it if possible.") -- output a message to the player 
        end 
end 
addCommandHandler("ping", checkPing) 

Ihope u guys can help me

Link to comment
Guest Guest4401
local maxPing = 100 
  
setTimer( 
    function() 
        for i,v in ipairs(getElementsByType'player') do -- loop through all players 
            if getPlayerPing(v) >= maxPing then -- if a player's ping is too high 
                kickPlayer(v,"You got kicked for having a high ping") -- kick him 
            end 
        end 
    end, 1000, 0 -- repeat the check every 1 second 
) 

Link to comment

is this correct ?

Serverping.lua

function checkPing() 
   local maxPing = 100 
  
setTimer( 
    function() 
        for i,v in ipairs(getElementsByType'player') do -- loop through all players 
            if getPlayerPing(v) >= maxPing then -- if a player's ping is too high 
                kickPlayer(v,"You got kicked for having a high ping") -- kick him 
            end 
        end 
    end, 1000, 0 -- repeat the check every 1 second 
) 

Link to comment
local maxPing = 100 
  
setTimer ( 
    function ( ) 
        for i, v in ipairs ( getElementsByType'player' ) do -- loop through all players 
            if ( getPlayerPing ( v ) >= maxPing ) then -- if a player's ping is too high 
                kickPlayer ( v, "You got kicked for having a high ping" ) -- kick him 
            end 
        end 
    end 
    ,1000, 0 -- repeat the check every 1 second 
) 

"checkPing" function was useless.

Link to comment

May I point out that a good anti-highping script will first WARN the player and then give him enough time to fix the problem before kicking him. Also, a good anti-highping script will take notice of people whether or not they are downloading at the time of the ping check. It doesn't make sense kicking someone who's downloading your server resources because he has 1000 ping.

Try to create these features if you want to be thorough.

Link to comment

i got now this:

Meta.xml

<meta> 
  <info author="StreetSaintz" version="1.0" /> 
  <script src="clientping.lua" type="client" /> 
</meta> 

clientping.lua

   local maxPing = 20 
  
setTimer ( 
    function ( ) 
        for i, v in ipairs ( getElementsByType'player' ) do -- loop through all players 
            if ( getPlayerPing ( v ) >= maxPing ) then -- if a player's ping is too high 
                kickPlayer ( v, "You got kicked for having a high ping" ) -- kick him 
            end 
        end 
    end 
    ,1000, 0 -- repeat the check every 1 second 
) 

What im doing wrong ?

Link to comment
You must add resource.resourceName in the acl group: Admin.

Thanks all guys , it works 100 %

so you'll just kick players as soon as their ping gets over the limit? What if they have a lagspike?

No, i got a other script that gives the player a warning when he gets over 250 ping and when he gets 300 ping = kick

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