Scripting/Squirrel/Functions/Players/Ping

From VC-MP Wiki

Jump to: navigation, search

This instance variable returns player's ping to the server.

Syntax

int player.Ping

Example

This command tells player their ping when they type '/c myping'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "myping" )
     {
          MessagePlayer( "Your ping: " + player.Ping, player );
     }
}

Example2

This command tells player their ping when they type '/c playerping'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "playerping" )
     {
     local plr = FindPlayer( text );
 
      if ( !plr ) MessagePlayer( "Player '" + text + "' is not online.", player );
      else MessagePlayer( plr.Name + "'s Ping: " + plr.Ping, player );
     }
}

Example3

This command kick players after spawn:

function onPlayerSpawn( player )
{
if ( player.Ping >= 150 ) Kick( player, "auto", "Too High ping" );
}

Notes

The function MessagePlayer and call onPlayerCommand were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
squirrel scripting