GetPlayerBySteamId: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|Gets a player by SteamID.}} {{FuncSyntax|GetPlayerBySteamId(steamid)}} {{FuncParameters}} {{FuncParam|steamid|The SteamId64 a..."
 
28days (talk | contribs)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0.3}}


{{FuncDescription|Gets a player by SteamID.}}
{{FuncDescription|Gets a player by SteamID.}}
Line 12: Line 12:
== Example ==
== Example ==
<syntaxhighlight lang="Lua">
<syntaxhighlight lang="Lua">
__EDIT_ME__
AddCommand("steamid", function (playerid, steam64)
    local length = string.len(steam64)
    if (length < 17 or length > 17) then
        return AddPlayerChat(playerid, "Invalid Steam64 length specified.")
    end
 
    local lookupid = GetPlayerSteamId(tonumber(steam64))
    if (lookupid == false) then
        return AddPlayerChat(playerid, "The specified Steam64 is not in game.")
    else
        return AddPlayerChat(playerid, "The specified Steam64 is online and their player ID: "..lookupid..".")
    end
end)
</syntaxhighlight>
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
* [[GetPlayerCount]]
{{ServerPlayerFunctions}}

Latest revision as of 10:04, 20 January 2020

GetPlayerBySteamId

Type: Function
Context: Server
Introduced: v1.0.3

Description

Gets a player by SteamID.

Syntax

GetPlayerBySteamId(steamid)

Parameters

  • steamid
    The SteamId64 as an integer.

Return Value

  • Returns the player identifier. Returns false if no player has the specified steamid.

Example

AddCommand("steamid", function (playerid, steam64)
    local length = string.len(steam64)
    if (length < 17 or length > 17) then
        return AddPlayerChat(playerid, "Invalid Steam64 length specified.")
    end

    local lookupid = GetPlayerSteamId(tonumber(steam64))
    if (lookupid == false) then
        return AddPlayerChat(playerid, "The specified Steam64 is not in game.")
    else
        return AddPlayerChat(playerid, "The specified Steam64 is online and their player ID: "..lookupid..".")
    end
end)

See also