Raised This Month: $51 Target: $400
 12% 

A way to get client's name by steam id64


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PunkChop
Junior Member
Join Date: Jul 2018
Old 07-29-2018 , 19:06   A way to get client's name by steam id64
Reply With Quote #1

there a way to get client name from steamid64?
PunkChop is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 07-29-2018 , 22:26   Re: A way to get client's name by steam id64
Reply With Quote #2

I'm not sure but this is what I would do if you want to get their name and Steam ID 64:

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    
char sID[64];
    
GetClientAuthId(clientAuthId_SteamID64sIDsizeof(sID));
    
PrintToChatAll("Name: %N, Steam ID 64: %s"clientsID);

__________________
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-29-2018 , 22:39   Re: A way to get client's name by steam id64
Reply With Quote #3

it depends...
do you want to get client's name when client is inside the server?
or get their name when they are not on the server
__________________
8guawong is offline
PunkChop
Junior Member
Join Date: Jul 2018
Old 07-30-2018 , 02:40   Re: A way to get client's name by steam id64
Reply With Quote #4

Quote:
Originally Posted by 8guawong View Post
it depends...
do you want to get client's name when client is inside the server?
or get their name when they are not on the server
Quote:
Originally Posted by Crasher_3637 View Post
I'm not sure but this is what I would do if you want to get their name and Steam ID 64:

PHP Code:
public void OnClientPostAdminCheck(int client)
{
    
char sID[64];
    
GetClientAuthId(clientAuthId_SteamID64sIDsizeof(sID));
    
PrintToChatAll("Name: %N, Steam ID 64: %s"clientsID);

i used in GetClientAuthId for steamid64 and now i have only steamid64 without client.. there cases that the client not in the server
i'm using in sql for saving his steamid64 and i want to do ktop.. so everytime i want get name with steamid64

Last edited by PunkChop; 07-30-2018 at 02:41.
PunkChop is offline
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 07-30-2018 , 03:02   Re: A way to get client's name by steam id64
Reply With Quote #5

You probably wanna use steamworks. To get player name you wanna get "personaname" from this http request:

http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v1/?key=<inserturapikey>&format=vdf&steamids=<in sertsteamid64>

Heres some example code I did some time ago to print ban status when he connects. Just do kv.GetString("personaname", buffer, sizeof(buffer)) in SummaryGetHTTPRequest callback.

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Rachnus"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <SteamWorks>

#pragma newdecls required

int g_iVisibility[MAXPLAYERS 1];
char g_iTradeBan[MAXPLAYERS 1][32];
bool g_bCallback1 false;
bool g_bCallback2 false;


public 
Plugin myinfo 
{
    
name "Connection Info",
    
author PLUGIN_AUTHOR,
    
description "Displays players information on connect",
    
version PLUGIN_VERSION,
    
url "https://github.com/Rachnus"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_test"Command_Test);
}

public 
Action Command_Test(int clientint args)
{
    
PrintConnectionInfo(client);
}

public 
void OnClientDisconnect(int client)
{
    
g_iVisibility[client] = 0;
}

public 
void OnClientAuthorized(int client, const char[] auth)
{    
    
PrintToChatAll("test");
    
char authid[64];
    
GetClientAuthId(clientAuthId_SteamID64authidsizeof(authid));
    
    
Handle SummaryHTTPRequest SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET"https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2/?");
    
Handle VacHTTPRequest SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET"https://api.steampowered.com/ISteamUser/GetPlayerBans/v1/?");
    
    
SteamWorks_SetHTTPRequestNetworkActivityTimeout(SummaryHTTPRequest10);
    
SteamWorks_SetHTTPRequestNetworkActivityTimeout(VacHTTPRequest10);
    
    
SteamWorks_SetHTTPRequestGetOrPostParameter(SummaryHTTPRequest"key"""); //Insert ur steam api key
    
SteamWorks_SetHTTPRequestGetOrPostParameter(SummaryHTTPRequest"format""vdf");
    
SteamWorks_SetHTTPRequestGetOrPostParameter(SummaryHTTPRequest"steamids"authid);
    
    
SteamWorks_SetHTTPRequestGetOrPostParameter(VacHTTPRequest"key""");//Insert ur steam api key
    
SteamWorks_SetHTTPRequestGetOrPostParameter(VacHTTPRequest"format""vdf");
    
SteamWorks_SetHTTPRequestGetOrPostParameter(VacHTTPRequest"steamids"authid);

    
SteamWorks_SetHTTPRequestContextValue(SummaryHTTPRequestGetClientUserId(client));
    
SteamWorks_SetHTTPRequestContextValue(VacHTTPRequestGetClientUserId(client));
    
    
SteamWorks_SetHTTPCallbacks(SummaryHTTPRequestSummaryGetHTTPRequest);
    
SteamWorks_SetHTTPCallbacks(VacHTTPRequestVacGetHTTPRequest);
    
    
SteamWorks_SendHTTPRequest(SummaryHTTPRequest);
    
SteamWorks_SendHTTPRequest(VacHTTPRequest);
    
    
SteamWorks_PrioritizeHTTPRequest(SummaryHTTPRequest);
    
SteamWorks_PrioritizeHTTPRequest(VacHTTPRequest);
}

void PrintConnectionInfo(int client)
{
    
char authid[64];
    
GetClientAuthId(clientAuthId_SteamID64authidsizeof(authid));
    
char connectionString[256];
    
char clientName[MAX_NAME_LENGTH];
    
GetClientName(clientclientNamesizeof(clientName));
    
Format(connectionStringsizeof(connectionString), "%s has connected [%s] [Profile: %s Trade Ban: %s]"clientNameauthid, (g_iVisibility[client] == 3) ? "Public" "Private", (StrEqual(g_iTradeBan[client], "none"false)) ? "Clean" "Banned");
    
PrintToChatAll("%s"connectionString);
    
PrintToServer("%s"connectionString);
    
PrintToServer("VISIBILITY %d TRADE BAN %s"g_iVisibility[client], g_iTradeBan[client]);
}

public 
int SummaryGetHTTPRequest(Handle hRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeany data1
{
    if(!
bRequestSuccessful
    {
        
CloseHandle(hRequest);
        return;
    }
    
    
int client GetClientOfUserId(data1);
    if(
client 0)
    {
        
char steamcid[32];
        
SteamWorks_GetClientSteamID(clientsteamcidsizeof(steamcid));
        
        
int bodyBufferSize;
        
SteamWorks_GetHTTPResponseBodySize(hRequestbodyBufferSize);
        
char[] bodyBuffer2 = new char[bodyBufferSize];
        
bool bodyData SteamWorks_GetHTTPResponseBodyData(hRequestbodyBuffer2bodyBufferSize);
        
        
// Could not get body data or body data is blank
        
if(bodyData == false
        {
            
CloseHandle(hRequest);
            return;
        }
        
        
CloseHandle(hRequest);
        
        
KeyValues kv = new KeyValues("PlayerVac");
        
kv.ImportFromString(bodyBuffer2"bodyBuffer2");
        if(!
kv.JumpToKey("players"))
            return;
        
        if(
kv.GotoFirstSubKey())
        {
            
g_iVisibility[client] = kv.GetNum("communityvisibilitystate");
            
PrintToServer("GOTO FIRST SUB");
        }
        
char buffername[64];
        
kv.GetSectionName(buffernamesizeof(buffername));
        
PrintToServer("BUFFERNAME %s"buffername);
        
PrintToServer("VISIBILITY %d"g_iVisibility[client]);
        
kv.Rewind();
        
kv.ExportToFile("testing1");
        
g_bCallback1 true;
        if(
g_bCallback1 && g_bCallback2)
        {
            
g_bCallback1 false;
            
g_bCallback2 false;
            
PrintConnectionInfo(client);
        }
        
    }
    else
        
CloseHandle(hRequest);
}


public 
int VacGetHTTPRequest(Handle hRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeany data1
{
    if(!
bRequestSuccessful
    {
        
CloseHandle(hRequest);
        return;
    }
    
    
int client GetClientOfUserId(data1);
    if(
client 0)
    {
        
char steamcid[32];
        
SteamWorks_GetClientSteamID(clientsteamcidsizeof(steamcid));
        
        
int bodyBufferSize;
        
SteamWorks_GetHTTPResponseBodySize(hRequestbodyBufferSize);
        
char[] bodyBuffer = new char[bodyBufferSize];
        
bool bodyData SteamWorks_GetHTTPResponseBodyData(hRequestbodyBufferbodyBufferSize);
        
        
// Could not get body data or body data is blank
        
if(bodyData == false
        {
            
CloseHandle(hRequest);
            return;
        }
        
        
CloseHandle(hRequest);
        
        
KeyValues kv = new KeyValues("PlayerStatus");
        
kv.ImportFromString(bodyBuffer"bodyBuffer");
        if(!
kv.JumpToKey("players"))
            return;

        if(
kv.GotoFirstSubKey())
            
kv.GetString("EconomyBan"g_iTradeBan[client], 32);
        
        
g_bCallback2 true;
        if(
g_bCallback1 && g_bCallback2)
        {
            
g_bCallback1 false;
            
g_bCallback2 false;
            
PrintConnectionInfo(client);
        }
        
        
//kv.ExportToFile("testing2");
    
}
    else
        
CloseHandle(hRequest);

__________________
Github: https://github.com/jimppan
Steam: http://steamcommunity.com/id/jimppan
_____________________________________________ _________
Taking private requests

Last edited by Rachnus; 07-30-2018 at 03:05.
Rachnus is offline
PunkChop
Junior Member
Join Date: Jul 2018
Old 07-30-2018 , 03:27   Re: A way to get client's name by steam id64
Reply With Quote #6

Quote:
Originally Posted by Rachnus View Post
You probably wanna use steamworks. To get player name you wanna get "personaname" from this http request:

http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v1/?key=<inserturapikey>&format=vdf&steamids=<in sertsteamid64>

Heres some example code I did some time ago to print ban status when he connects. Just do kv.GetString("personaname", buffer, sizeof(buffer)) in SummaryGetHTTPRequest callback.
but it will work with only steamid64? it seem to me that you need the client to be connected bacause OnClientAuthorized()

Last edited by PunkChop; 07-30-2018 at 03:28.
PunkChop is offline
Rachnus
Senior Member
Join Date: Jun 2016
Location: Funland
Old 07-30-2018 , 03:30   Re: A way to get client's name by steam id64
Reply With Quote #7

The client for whom you are getting the player name of will not be required to be in game. Im only passing in client as an argument to the callback because I only want to print the info if he is in-game. (Should probably change OnClientAuthorized to OnClientPostAdminCheck)

EDIT: also if you do not want to do all this you could just store their name in the SQL table, but this would only get updated once the player joins/disconnects from your server.
__________________
Github: https://github.com/jimppan
Steam: http://steamcommunity.com/id/jimppan
_____________________________________________ _________
Taking private requests

Last edited by Rachnus; 07-30-2018 at 03:47.
Rachnus is offline
PunkChop
Junior Member
Join Date: Jul 2018
Old 07-30-2018 , 03:49   Re: A way to get client's name by steam id64
Reply With Quote #8

Quote:
Originally Posted by Rachnus View Post
The client for whom you are getting the player name of will not be required to be in game. Im only passing in client as an argument to the callback because I only want to print the info if he is in-game. (Should probably change OnClientAuthorized to OnClientPostAdminCheck)

EDIT: also if you do not want to do all this you could just store their name in the SQL table, but this would only get updated once the player joins/disconnects from your server.
you right.. it will be easier if ill just add name to sql.. ill update name every time that client join..
PunkChop is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:12.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode