Jump to content

Odd changes from boolean to string


Blueman

Recommended Posts

Well the console keeps claiming that this is a string then I make some changes to convert it from a string to a int and it says it is a Boolean.

Ping.lua

  
PingTable = { } 
  
function PingCheck(source) 
if (getPlayerPing(sourcer) > get("MaxPing")) then 
    kickPlayer(ThePlayer, "High Ping") 
else 
   outputConsle( ThePlayer.. "Has passed the ping check") 
 end 
end 
  
function onPlayerJoinGame() 
table.insert(PingTable ,setTimer(PingCheck, tonumber(get("Delay")), 1 , source) 
) 
end 
addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoinGame) 
  

Meta.xml

  
<Meta> 
<info author="Blueman" type="script" name="Ping Kicker" /> 
<script src="Ping.lua" type="server"/> 
<settings>  
<setting name="MaxPing" value="50"/>  
<setting name="Delay" value="10000"/> 
</settings> 
</Meta> 
  

Link to comment
PingTable = { } 
  
function PingCheck(source) 
if (getPlayerPing(sourcer) > tonumber(get("MaxPing"))) then 
    kickPlayer(ThePlayer, "High Ping") 
else 
   outputConsle( ThePlayer.. "Has passed the ping check") 
 end 
end 
  
function onPlayerJoinGame() 
table.insert(PingTable ,setTimer(PingCheck, tonumber(get("Delay")), 1 , source) 
) 
end 
addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoinGame) 

Link to comment

JR10's script works just fine, this ones just a little bit organized.

local PingTable = {} 
  
function PingCheck(source) 
    if getPlayerPing(source) > tonumber(get("MaxPing")) then 
        kickPlayer(source, "High Ping") 
    else 
        outputConsle(getPlayerName(source) .. " has passed the ping check.") 
    end 
end 
  
addEventHandler("onPlayerJoin", getRootElement(), 
    function() 
        table.insert(PingTable, setTimer(PingCheck, tonumber(get("Delay")), 1, source) 
    end 
) 

Edited by Guest
Link to comment

Server

local PingTable = { } 
  
local default_time = 10000  
  
addEventHandler( 'onPlayerJoin', root, 
    function( ) 
        PingTable [ source ] = setTimer(  
            function( player ) 
                if getPlayerPing( player ) > tonumber( get( 'MaxPing' ) ) then 
                    kickPlayer( player, "High Ping" ) 
                else 
                    outputConsole( '*'..getPlayerName( player ).. ' Has passed the ping check' ) 
                end 
            end, 
        tonumber( get( "Delay" ) or default_time ), 
        0 , source )     
    end 
) 
  
addEventHandler( 'onPlayerQuit', root, 
    function( ) 
        if isTimer( PingTable [ source ] ) then  
            killTimer( PingTable [ source ] ) 
        end 
        PingTable [ source ] = nil 
    end 
)    

Link to comment

You should also disable kicking when players are downloading, because some people get like 5-10 times more ping when they do, even thought the download is may only be 2-5 seconds long. Would suck if 1/4 of the players each round got kicked.

(If you had not thought about that yet)

Link to comment

One problem you set the amount of times to repeat to 0 causing an infinite loop.

  
local PingTable = { } 
  
local default_time = 10000 
  
addEventHandler( 'onPlayerJoin', root, 
    function( ) 
        PingTable [ source ] = setTimer( 
            function( player ) 
                if getPlayerPing( player ) > tonumber( get( 'MaxPing' ) ) then 
                    kickPlayer( player, "High Ping" ) 
                else 
                    outputDebugString( '*'..getPlayerName( player ).. ' Has passed the ping check' ) 
                end 
            end, 
        tonumber( get( "Delay" ) or default_time ), 
        1 , source )    
    end 
) 
  
addEventHandler( 'onPlayerQuit', root, 
    function( ) 
        if isTimer( PingTable [ source ] ) then 
            killTimer( PingTable [ source ] ) 
        end 
        PingTable [ source ] = nil 
    end 
) 
  

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