View Single Post
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 04-15-2019 , 06:59   Re: [CSGO] check profile status in csgo
Reply With Quote #5

thank you guys!

i used this web api:
PHP Code:
http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=xxxxxxxxxxxxxxxxxxx&appids_filter[0]=730&steamid=xxxxxxxxxxxxxxx&format=vdf 
output web api:
PHP Code:
"response"
{
    
"game_count"    "1"
    "games"
    
{
        
"0"
        
{
            
"appid"    "730"
            "playtime_2weeks"    "3235"
            "playtime_forever"    "134262"
        
}
    }

new code:
PHP Code:

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

#define STEAM_API_KEY "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
#define GAME_TYPE "730"

public void OnClientPostAdminCheck(int client)
{
    
SetToDefaults(client);
    
    if(
IsValidClient(client))
    {
        if(
sm_cac_hourcheck.BoolValue)
        {
            
Handle request CreateRequest_TimePlayed(client);
            
SteamWorks_SendHTTPRequest(request);
        }
    }
}

Handle CreateRequest_TimePlayed(int client)
{
    
char steamid64[64];
    
GetClientAuthId(clientAuthId_SteamID64steamid64sizeof(steamid64));
    if (
IsFakeClient(client) || !GetClientAuthId(clientAuthId_SteamID64steamid64sizeof(steamid64)))
    {
        
CowAC_Log("steamid Faild!!")
        return;
    }
    
    
Handle request SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET"http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/");
    
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"key"STEAM_API_KEY);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"appids_filter[0]"GAME_TYPE);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"steamid"steamid64);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"format""vdf");
    
    
SteamWorks_SetHTTPRequestContextValue(requestclient);
    
    
SteamWorks_SetHTTPCallbacks(requestTimePlayed_OnHTTPResponse);
    
    return 
request;
}

public 
int TimePlayed_OnHTTPResponse(Handle requestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint client)
{
    if(!
bFailure && bRequestSuccessful && eStatusCode == k_EHTTPStatusCode200OK)
        
SteamWorks_GetHTTPResponseBodyCallback(requestAPIWebResponse);
    
CowAC_Log("Could not get Steam level (HTTP status %d)"eStatusCode);
    
delete request;
    return 
0;
}

public 
void APIWebResponse(char[] response)
{
    
KeyValues Kv = new KeyValues("response");
    
Kv.SetEscapeSequences(true);
    if(
Kv.ImportFromString(response))
    {
        if(
Kv.JumpToKey("games"))
        {
            if(
Kv.JumpToKey("0"))
            {
                
float g_timeplay[64];
                
Kv.GetFloat("playtime_forever"g_timeplaysizeof(g_timeplay));
                if(
RoundFloat(g_timeplay) < sm_cac_hourcheck_value.IntValue)
                {
                    
KickClient(client"You do not meet the minimum hour requirement to play here! (%i/%i)"RoundFloat(g_timeplay), sm_cac_hourcheck_value.IntValue);
                    
delete Kv;
                }
            }
            else 
delete Kv;
        }
        else 
delete Kv;
    }
    else 
delete Kv;

please check and help me for fix

Last edited by DarkDeviL; 01-10-2022 at 21:17. Reason: Censored Steam API key
Dr.Mohammad is offline