Jump to content

Odd changes from boolean to string


Blueman

Recommended Posts

Posted

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> 
  

Posted
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) 

Posted (edited)

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
Posted

outputConsle( ThePlayer.. "Has passed the ping check") there is no Player in the script dosnt it have to be

outputConsle( source .. "Has passed the ping check")

or

outputConsle( localPlayer .. "Has passed the ping check")

Posted

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 
)    

Posted

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)

Posted

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 
) 
  

Posted

Not understand you.

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

You need just check if player download?

And ping < limit

LOL.

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