Raised This Month: $82 Target: $400
 20% 

[CSGO] check profile status in csgo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 04-13-2019 , 02:18   [CSGO] check profile status in csgo
Reply With Quote #1

hi guys!
i need to check the time play csgo for this plugin!!
check profile status and Minimum amount of playtime a user has to have on CSGO must 50 hours for join to server.

please help me !!
this cod dont work for me

sorry for bad speak english

simple cod(cowac edited):
https://github.com/Deniel00/Cow-Anti...owanticheat.sp
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <SteamWorks>

public void OnPluginStart()
{
    
sm_cac_hourcheck CreateConVar("sm_cac_hourcheck""1""Enable hour checker (1 = Yes, 0 = No)"FCVAR_NOTIFYtrue0.0true1.0);
    
sm_cac_hourcheck_value CreateConVar("sm_cac_hourcheck_value""50""Minimum amount of playtime a user has to have on CS:GO (Default: 50)");
    
sm_cac_profilecheck CreateConVar("sm_cac_profilecheck""1""Enable profile checker, this makes it so users need to have a public profile to connect. (1 = Yes, 0 = No)"FCVAR_NOTIFYtrue0.0true1.0);
    
sm_cac_steamapi_key CreateConVar("sm_cac_steamapi_key""xxxxxxxxxxxxxxxxxxxxxxxxxxxx""Need for ProfileCheck and HourCheck. (https://steamcommunity.com/dev/apikey)"FCVAR_NOTIFY);
}

public 
void OnClientPutInServer(int client)
{
    if(
IsValidClient(client))
    {
        if(
sm_cac_profilecheck.BoolValue)
        {
            
Handle request CreateRequest_ProfileStatus(client);
            
SteamWorks_SendHTTPRequest(request);
        }
        
        if(
sm_cac_hourcheck.BoolValue)
        {
            
Handle request CreateRequest_TimePlayed(client);
            
SteamWorks_SendHTTPRequest(request);
        }
    }
}

Handle CreateRequest_TimePlayed(int client)
{
    
char request_url[256];
    
char s_Steamapi[256];
    
sm_cac_steamapi_key.GetString(s_Steamapisizeof(s_Steamapi));
    
Format(request_urlsizeof(request_url), "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=%s",s_Steamapi);
    
Handle request SteamWorks_CreateHTTPRequest(k_EHTTPMethodGETrequest_url);
    
    
char steamid[64];
    
GetClientAuthId(clientAuthId_SteamID64steamidsizeof(steamid));
    
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"steamid"steamid);
    
SteamWorks_SetHTTPRequestContextValue(requestclient);
    
SteamWorks_SetHTTPCallbacks(requestTimePlayed_OnHTTPResponse);
    return 
request;
}

public 
int TimePlayed_OnHTTPResponse(Handle requestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint client)
{
    if (!
bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
    {
        
delete request;
        return;
    }

    
int iBufferSize;
    
SteamWorks_GetHTTPResponseBodySize(requestiBufferSize);
    
    
char[] sBody = new char[iBufferSize];
    
SteamWorks_GetHTTPResponseBodyData(requestsBodyiBufferSize);
    
    
int time StringToInt(sBody10) / 60 60;
    
    if(
time <= 0)
    {
        
KickClient(client"Please connect with a public steam profile.");
    }
    else if(
time sm_cac_hourcheck_value.IntValue)
    {
        
KickClient(client"You do not meet the minimum hour requirement to play here! (%i/%i)"timesm_cac_hourcheck_value.IntValue);
    }
    
    
delete request;
}

Handle CreateRequest_ProfileStatus(int client)
{
    
char request_url[256];
    
char s_Steamapi[256];
    
sm_cac_steamapi_key.GetString(s_Steamapisizeof(s_Steamapi));
    
Format(request_urlsizeof(request_url), "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=%s",s_Steamapi);
    
Handle request SteamWorks_CreateHTTPRequest(k_EHTTPMethodGETrequest_url);
    
    
char steamid[64];
    
GetClientAuthId(clientAuthId_SteamID64steamidsizeof(steamid));
    
    
SteamWorks_SetHTTPRequestGetOrPostParameter(request"steamid"steamid);
    
SteamWorks_SetHTTPRequestContextValue(requestclient);
    
SteamWorks_SetHTTPCallbacks(requestProfileStatus_OnHTTPResponse);
    return 
request;
}

public 
int ProfileStatus_OnHTTPResponse(Handle requestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint client)
{
    if (!
bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
    {
        
delete request;
        return;
    }

    
int iBufferSize;
    
SteamWorks_GetHTTPResponseBodySize(requestiBufferSize);
    
    
char[] sBody = new char[iBufferSize];
    
SteamWorks_GetHTTPResponseBodyData(requestsBodyiBufferSize);
    
    
int profile StringToInt(sBody10) / 60 60;
    
    if(
profile 3)
    {
        
KickClient(client"Please connect with a public steam profile.");
    }
    
    
delete request;


Last edited by Dr.Mohammad; 04-13-2019 at 02:21.
Dr.Mohammad is offline
Ilusion9
Senior Member
Join Date: Jun 2018
Location: Romania
Old 04-13-2019 , 06:24   Re: [CSGO] check profile status in csgo
Reply With Quote #2

Use OnClientPostAdminCheck instead of OnClientPutInServer (clients might not have a valid steamid in that function).

https://sm.alliedmods.net/new-api/cl...entPutInServer
__________________
Ilusion9 is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 04-13-2019 , 08:59   Re: [CSGO] check profile status in csgo
Reply With Quote #3

Quote:
Originally Posted by Ilusion9 View Post
Use OnClientPostAdminCheck instead of OnClientPutInServer (clients might not have a valid steamid in that function).

https://sm.alliedmods.net/new-api/cl...entPutInServer
dont work:
PHP Code:
public void OnClientPostAdminCheck(int client)
{
    
SetToDefaults(client);
    
    if(
IsValidClient(client))
    {
        if(
sm_cac_profilecheck.BoolValue)
        {
            
Handle request CreateRequest_ProfileStatus(client);
            
SteamWorks_SendHTTPRequest(request);
        }
        
        if(
sm_cac_hourcheck.BoolValue)
        {
            
Handle request CreateRequest_TimePlayed(client);
            
SteamWorks_SendHTTPRequest(request);
        }
    }

Dr.Mohammad is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 04-14-2019 , 15:06   Re: [CSGO] check profile status in csgo
Reply With Quote #4

I do not want the game to enter my server less than 200 hours. I bought a plugin. it was checking the game hours with the link in the plugin.

http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={key}&appids_filter[0]={game}&steamid={steamid}&format=json

Even if the game hours of the new player is hidden, the game hours can be controlled by this link.
__________________
alphaearth is offline
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 "9028BAA61070271A7809C3293E0C72D0"
#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 Dr.Mohammad; 04-15-2019 at 07:04.
Dr.Mohammad is offline
alphaearth
Senior Member
Join Date: Feb 2018
Location: Turkey
Old 04-15-2019 , 09:12   Re: [CSGO] check profile status in csgo
Reply With Quote #6

Quote:
Originally Posted by Dr.Mohammad View Post
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 "9028BAA61070271A7809C3293E0C72D0"
#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
Please correct?
__________________
alphaearth is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 04-16-2019 , 01:00   Re: [CSGO] check profile status in csgo
Reply With Quote #7

Quote:
Originally Posted by alphaearth View Post
Please correct?
hi!!
i very try but this plugin don't work (
i dont know what problem !!

debug log:
PHP Code:
L 04/16/2019 09:04:02GetPlayTime.
L 04/16/2019 09:04:02SendHTTPRequest.
L 04/16/2019 09:04:02OnClientPostAdminCheck.
L 04/16/2019 09:04:02HTTPResponseBody
L 04
/16/2019 09:04:02k_EHTTPStatusCode200OK
my plugin:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <SteamWorks>

#pragma semicolon 1
#pragma newdecls required

#define STEAM_API_KEY "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#define GAME_TYPE "730"

char g_szLogFile[PLATFORM_MAX_PATH];

public 
Plugin myinfo =
{
    
name        =     "Block New Accounts",
    
author        =     "Dr.Mohammad",
    
version        =     "1.0",
    
description =    "Checks players account time play.",
    
url            =     "",
};

public 
void OnPluginStart()
{
    
BuildPath(Path_SMg_szLogFilesizeof(g_szLogFile), "logs/BNA.log");
}

public 
void OnClientPostAdminCheck(int client)
{
    if(
IsValidClient(client))
    {
        
GetPlayTime(client);
        
LogToFileEx(g_szLogFile,"OnClientPostAdminCheck.");
    }
}

void GetPlayTime(int iClient)
{
    
char sSteamID64[20];
    
GetClientAuthId(iClientAuthId_SteamID64sSteamID64sizeof(sSteamID64));
    
    
LogToFileEx(g_szLogFile,"GetPlayTime.");
    
    
/* HEADER */
    
Handle hRequest SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET"http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/");
    
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest"key"STEAM_API_KEY);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest"appids_filter[0]"GAME_TYPE);
    
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest"steamid"sSteamID64);
    
    
/* OPTIONS */
    
SteamWorks_WriteHTTPResponseBodyToFile(hRequest"steamwork_response.txt");
    
SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest10);
    
SteamWorks_SetHTTPCallbacks(hRequestHTTPRequestComplete);
    
    
SteamWorks_SetHTTPRequestContextValue(hRequestGetClientSerial(iClient));
    
    
SteamWorks_SendHTTPRequest(hRequest);
    
LogToFileEx(g_szLogFile,"SendHTTPRequest.");
}


public 
void HTTPRequestComplete(Handle hRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeany iClient)
{
    if (
bFailure && !bRequestSuccessful && eStatusCode != k_EHTTPStatusCode200OK)
    {
        
LogToFileEx(g_szLogFile,"error %d."eStatusCode);
        
delete hRequest;
        return;
    }
    
    
iClient GetClientFromSerial(iClient);
    
SteamWorks_GetHTTPResponseBodyCallback(hRequestHTTPResponseBodyGetClientSerial(iClient));
    
LogToFileEx(g_szLogFile,"k_EHTTPStatusCode200OK.");
}

public 
int HTTPResponseBody(const char[] sDataint iClient)
{
    if((
iClient GetClientFromSerial(iClient)) != 0)
    {
        
LogToFileEx(g_szLogFile,"HTTPResponseBody");
        
char sBuffer[12];
        if(
SplitString(sData[StrContains(sData"\"playtime_forever\":")+3], ","sBuffersizeof(sBuffer)) != -1)
        {
            
LogToFileEx(g_szLogFile,"sbuffer: %s"sBuffer);
            
int g_iTimePlay 0;
            if(
g_iTimePlay <= 0)
            {
                
LogToFileEx(g_szLogFile,"%N Please connect with a public steam profile."iClient);
            }
            else if(
g_iTimePlay 50)
            {
                
LogToFileEx(g_szLogFile,"%N You do not meet the minimum hour requirement to play here! (%i/50)"iClientg_iTimePlay);
            }
        }
    }
    return;
}

bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true)
{
    if(!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client)))
    {
        return 
false;
    }
    return 
true;

Guys please help
I will share this plugin after being completed!!
Dr.Mohammad is offline
Reply


Thread Tools
Display Modes

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 04:56.


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