GetPlayerBySteamId: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
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]]
* [[GetPlayerCount]]

Revision as of 09:59, 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