GetPlayerPing: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 8: Line 8:
{{FuncParam|playerid|The player identifier.}}
{{FuncParam|playerid|The player identifier.}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns the player ping in integer.}}


== Example ==
== Example ==
<syntaxhighlight lang="Lua>
<syntaxhighlight lang="Lua>
CreateTimer(PingKicker, 10000, function()
CreateTimer(function()
local ping = ServerData["max_ping"]
local ping = 400
for _, j in ipairs(GetAllPlayers()) do
for k, v in ipairs(GetAllPlayers()) do
if GetPlayerPing(j) > ping then
if GetPlayerPing(v) > ping then
KickPlayer(j, "You were kicked for high ping.")
KickPlayer(v, "You were kicked for high ping.")
end
end
end
end
end)
end, 10000)
</syntaxhighlight>
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
{{Template:PlayerFunctions}}
{{ServerPlayerFunctions}}

Latest revision as of 20:42, 27 May 2021

GetPlayerPing

Type: Function
Context: Server
Introduced: v1.0

Description

Get the ping of the specified player.

Syntax

GetPlayerPing(playerid)

Parameters

  • playerid
    The player identifier.

Return Value

  • Returns the player ping in integer.

Example

CreateTimer(function()
	local ping = 400
	for k, v in ipairs(GetAllPlayers()) do
		if GetPlayerPing(v) > ping then
			KickPlayer(v, "You were kicked for high ping.")
		end
	end
end, 10000)

See also