Jump to content

[HELP] It does not work: (


1LoL1

Recommended Posts

It does not work it does not kick at all .. :(or not write anything ..:( help anyone?

function checkPing(thePlayer) 
ping = getPlayerPing(thePlayer) 
if ( ping > 200 ) then 
kickPlayer (thePlayer ,Too high Ping) 
outputChatBox (getPlayerName(thePlayer).."was kicked for hight ping!",255,255,0 ) 
end 
addEventHandler ("OnResourceStart") 

Link to comment

You forgot apostrophes around the kick reason.

Also, your event handler is incorrectly written. It takes in three arguments (event name, event source and handler function).

You also have to loop through all players in order to check pings like that. You also forgot the second argument from the outputChatBox function (the target element(s), which is root for now).

function checkPing( ) 
    for _,player in ipairs( getElementsByType( "player" ) ) do 
        local ping = getPlayerPing( player ) 
        if ( ping > 200 ) then 
            kickPlayer( player, "High ping (" .. ping .. ">200)" ) 
            outputChatBox( getPlayerName( player ) .. " was kicked for high ping (" .. ping .. ">200)", root, 255, 255, 0 ) 
        end 
    end 
end 
addEventHandler( "onResourceStart", resourceRoot, checkPing ) 

Edited by Guest
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...