diff --git a/Extension/gsnatives.cpp b/Extension/gsnatives.cpp index e5e7ef2..7621f4d 100644 --- a/Extension/gsnatives.cpp +++ b/Extension/gsnatives.cpp @@ -200,6 +200,39 @@ static cell_t sm_GetClientSteamID(IPluginContext *pContext, const cell_t *params return numBytes; } +static cell_t sm_GetUserGroupStatus(IPluginContext *pContext, const cell_t *params) +{ + ISteamGameServer *pServer = GetGSPointer(); + + if (pServer == NULL) + { + return false; + } + + int client = gamehelpers->ReferenceToIndex(params[1]); + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); /* Man, including GameHelpers and PlayerHelpers for this native :(. */ + if (pPlayer == NULL || pPlayer->IsConnected() == false) + { + return pContext->ThrowNativeError("Client index %d is invalid", params[1]); + } + + CSteamID checkid = CreateCommonCSteamID(pPlayer, params); + return pServer->RequestUserGroupStatus(checkid, CSteamID(params[2], k_EUniversePublic, k_EAccountTypeClan)); +} + +static cell_t sm_GetUserGroupStatusAuthID(IPluginContext *pContext, const cell_t *params) +{ + ISteamGameServer *pServer = GetGSPointer(); + + if (pServer == NULL) + { + return false; + } + + CSteamID checkid = CreateCommonCSteamID(params[1], params, 3, 4); + return pServer->RequestUserGroupStatus(checkid, CSteamID(params[2], k_EUniversePublic, k_EAccountTypeClan)); +} + static sp_nativeinfo_t gsnatives[] = { {"SteamWorks_IsVACEnabled", sm_IsVACEnabled}, {"SteamWorks_GetPublicIP", sm_GetPublicIP}, @@ -212,6 +245,8 @@ static sp_nativeinfo_t gsnatives[] = { {"SteamWorks_ForceHeartbeat", sm_ForceHeartbeat}, {"SteamWorks_HasLicenseForApp", sm_UserHasLicenseForApp}, {"SteamWorks_GetClientSteamID", sm_GetClientSteamID}, + {"SteamWorks_GetUserGroupStatus", sm_GetUserGroupStatus}, + {"SteamWorks_GetUserGroupStatusAuthID", sm_GetUserGroupStatusAuthID}, {NULL, NULL} }; diff --git a/Extension/swforwards.cpp b/Extension/swforwards.cpp index bd13b06..6e46d39 100644 --- a/Extension/swforwards.cpp +++ b/Extension/swforwards.cpp @@ -23,13 +23,15 @@ SteamWorksForwards::SteamWorksForwards() : m_CallbackValidateTicket(this, &SteamWorksForwards::OnValidateTicket), m_CallbackSteamConnected(this, &SteamWorksForwards::OnSteamServersConnected), m_CallbackSteamConnectFailure(this, &SteamWorksForwards::OnSteamServersConnectFailure), - m_CallbackSteamDisconnected(this, &SteamWorksForwards::OnSteamServersDisconnected) + m_CallbackSteamDisconnected(this, &SteamWorksForwards::OnSteamServersDisconnected), + m_CallbackGroupStatus(this, &SteamWorksForwards::OnGroupStatusResult) { this->pFOVC_Old = forwards->CreateForward("SW_OnValidateClient", ET_Ignore, 2, NULL, Param_Cell, Param_Cell); this->pFOVC = forwards->CreateForward("SteamWorks_OnValidateClient", ET_Ignore, 2, NULL, Param_Cell, Param_Cell); this->pFOSSC = forwards->CreateForward("SteamWorks_SteamServersConnected", ET_Ignore, 0, NULL); this->pFOSSCF = forwards->CreateForward("SteamWorks_SteamServersConnectFailure", ET_Ignore, 1, NULL, Param_Cell); this->pFOSSD = forwards->CreateForward("SteamWorks_SteamServersDisconnected", ET_Ignore, 1, NULL, Param_Cell); + this->pFOCGS = forwards->CreateForward("SteamWorks_OnClientGroupStatus", ET_Ignore, 4, NULL, Param_Cell, Param_Cell, Param_Cell, Param_Cell); } SteamWorksForwards::~SteamWorksForwards() @@ -100,3 +102,16 @@ void SteamWorksForwards::OnSteamServersDisconnected(SteamServersDisconnected_t * this->pFOSSD->Execute(NULL); } +void SteamWorksForwards::OnGroupStatusResult(GSClientGroupStatus_t *pResponse) +{ + if (this->pFOCGS->GetFunctionCount() == 0) + { + return; + } + + this->pFOCGS->PushCell(pResonse->m_SteamIDUser.GetAccountID()); + this->pFOCGS->PushCell(pResonse->m_SteamIDGroup.GetAccountID()); + this->pFOCGS->PushCell(pResonse->m_bMember); + this->pFOCGS->PushCell(pResonse->m_bOfficer); + this->pFOCGS->Execute(NULL); +} \ No newline at end of file diff --git a/Extension/swforwards.h b/Extension/swforwards.h index deb1d25..62f051b 100644 --- a/Extension/swforwards.h +++ b/Extension/swforwards.h @@ -38,6 +38,7 @@ class SteamWorksForwards STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersConnected, SteamServersConnected_t, m_CallbackSteamConnected); STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersConnectFailure, SteamServerConnectFailure_t, m_CallbackSteamConnectFailure); STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnSteamServersDisconnected, SteamServersDisconnected_t, m_CallbackSteamDisconnected); + STEAM_GAMESERVER_CALLBACK(SteamWorksForwards, OnGroupStatusResult, GSClientGroupStatus_t, m_CallbackGroupStatus); private: IForward *pFOVC; /* Forward On Validate Client */ @@ -45,4 +46,5 @@ class SteamWorksForwards IForward *pFOSSC; /* Forward On Steam Servers Connected */ IForward *pFOSSCF; /* Forward On Steam Servers Connect Failure */ IForward *pFOSSD; /* Forward On Steam Servers Disconnected */ + IForward *pFOCGS; /* Forward On Client Group Status */ }; diff --git a/Pawn/includes/SteamWorks.inc b/Pawn/includes/SteamWorks.inc index 2d7871e..ef9965d 100644 --- a/Pawn/includes/SteamWorks.inc +++ b/Pawn/includes/SteamWorks.inc @@ -279,6 +279,8 @@ public __ext_SteamWorks_SetNTVOptional() MarkNativeAsOptional("SteamWorks_SetRule"); MarkNativeAsOptional("SteamWorks_ClearRules"); MarkNativeAsOptional("SteamWorks_ForceHeartbeat"); + MarkNativeAsOptional("SteamWorks_GetUserGroupStatus"); + MarkNativeAsOptional("SteamWorks_GetUserGroupStatusAuthID"); MarkNativeAsOptional("SteamWorks_HasLicenseForApp"); MarkNativeAsOptional("SteamWorks_GetClientSteamID");