iFoReX Posted April 18, 2012 Share Posted April 18, 2012 it is my code function VerPing() local ping = getPlayerPing(source) if (ping > 600) then outputChatbox("Cuidado Tu ping es muy alto : "..ping", Seras Kickeado ") nombre = getPlayerFromName(source) setTimer(kickear, 5000, 1) end end function kickear() if ( hasObjectPermissionTo ( sourcePlayer, "function.kickPlayer" ) ) then kickPlayer( nombre ) end end Link to comment
Castillo Posted April 18, 2012 Share Posted April 18, 2012 You've got many things wrong there. 1: You're not executing the function "VerPing" at all. 2: You don't need to use: hasObjectPermisionTo, you don't have to create the function "kickear" at all actually. 3: You're not passing any argument to "kickear" function. local kickTimers = { } function VerPing ( ) for index, player in ipairs ( getElementsByType ( "player" ) ) do local ping = getPlayerPing ( player ) if ( ping > 600 and not kickTimers [ player ] ) then outputChatBox ( "Cuidado Tu ping es muy alto : ".. ping ..", Seras Kickeado " ) kickTimers [ player ] = setTimer ( kickPlayer, 5000, 1, player ) end end end setTimer ( VerPing, 2000, 0 ) Every 2 seconds it'll check all player pings. Link to comment
Kenix Posted April 18, 2012 Share Posted April 18, 2012 Better create all in client side. if ping > 600 then trigger to server and kick player. Also you should add rights for this resource use "kickPlayer" function. Client --[[ Writed by Kenix Version: 1.0.0 ]] local nPingMax = 600 setTimer( function( nPingMax ) local nCurrentPing = getPlayerPing( localPlayer ) if nCurrentPing >= nPingMax then triggerServerEvent( 'Server:KickPlayer', localPlayer, nPingMax, nCurrentPing ) end end, 5000, 0, nPingMax ) Server addEvent( 'Server:KickPlayer', true ) addEventHandler( 'Server:KickPlayer', root, function( nPingMax, nCurrentPing ) kickPlayer( source, 'Your ping = ' .. tostring( nCurrentPing ) .. ' , Max ping = ' .. tostring( nPingMax ) ) end ) You can use it. I create this for my gm. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now