GetPlayerPing: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 7: | Line 7: | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePlayer''': The [[player]] whose ping you want to determine. | *'''thePlayer''': The [[player]] whose ping you want to determine. | ||
===Returns=== | |||
Returns an ''int'' with the ping, or ''false'' if the player is invalid. | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua"> | This example checks the ping of every player joining and warns him if it's over 100. | ||
outputChatBox ( " | <syntaxhighlight lang="lua"> | ||
function checkPing() | |||
local ping = getPlayerPing(source) -- get the ping from the source element (the player who joined) | |||
if (ping > 100) then -- if its higher than 100.. | |||
outputChatBox("Your ping is pretty high! Please try to lower it if possible.",source) -- output a message to the player | |||
end | |||
end | |||
addEventHandler("onPlayerJoin",getRootElement(),checkPing) -- add the event handler | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 13:35, 27 July 2007
This function returns the ping of a specified player. The ping is the number of milliseconds that data takes to travel from the player's client to the server or the reverse.
Syntax
int getPlayerPing ( player thePlayer )
Required Arguments
- thePlayer: The player whose ping you want to determine.
Returns
Returns an int with the ping, or false if the player is invalid.
Example
This example checks the ping of every player joining and warns him if it's over 100.
function checkPing() local ping = getPlayerPing(source) -- get the ping from the source element (the player who joined) if (ping > 100) then -- if its higher than 100.. outputChatBox("Your ping is pretty high! Please try to lower it if possible.",source) -- output a message to the player end end addEventHandler("onPlayerJoin",getRootElement(),checkPing) -- add the event handler
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState