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

[ANY] SteamWorks


Post New Thread Reply   
 
Thread Tools Display Modes
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 11-23-2020 , 09:49   Re: [ANY] SteamWorks
Reply With Quote #811

Quote:
Originally Posted by paulo_crash View Post
Would anyone know if the Windows version still works correctly?

I use this extension together with the CSGO SWGM Plugin, Linux version works all right. The Windows version runs and everything, but the plugin does not work.

Would anyone else have this problem, or would it be something in the plugin itself?

The plugin itself runs when the server starts for the first time, but changes the map to stop working.

I've checked error logs and nothing. Both the plugin and the SteamWorks extension still work, without errors, however the plugin does not do its job, it would block commands and check if the player is in the Steam Group.
Oops, anyone having this problem with Windows version? Is it due to the lack of this without the latest compiled version?
paulo_crash is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 01-01-2021 , 15:12   Re: [ANY] SteamWorks
Reply With Quote #812

I'm trying to build this extension and get 3 such errors:
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/swgchooks.cpp:28:1errordelete called on non-final '__SourceHook_FHCls_ISteamGameCoordinatorSendMessage0::CMyDelegateImpl' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
SH_DECL_HOOK3(ISteamGameCoordinatorSendMessageSH_NOATTRIB0EGCResultsuint32, const void *, uint32);
^
/
home/d/alliedmodders/mmsource-1.10/core/sourcehook/sourcehook.h:1696:3noteexpanded from macro 'SH_DECL_HOOK3'
                
MAKE_DELEG(rettype, (param1 p1param2 p2param3 p3), (p1p2p3)); \
                ^
/
home/d/alliedmodders/mmsource-1.10/core/sourcehook/sourcehook.h:1047:23noteexpanded from macro 'MAKE_DELEG'
                
void DeleteThis() { delete this; } \ 
PHP Code:
/home/d/alliedmodders/sourcemod/public/amtl/amtl/am-string.h:110:28errorno member named 'make_unique' in namespace 'std'
        
auto buffer std::make_unique<char[]>(1); 
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/extension.cpp:74:2errordelete called on non-final 'SteamWorksHTTP' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
        
delete this->pSWHTTP
I'm using the latest SDK and clang 3.8. What could be the reason?
Also I had to add these pathes (ambuild couldn't find some headers):
Quote:
os.path.join(self.sm_root, 'sourcepawn', 'include'),
os.path.join(self.sm_root, 'public', 'amtl'),
os.path.join(self.sm_root, 'public', 'amtl', 'amtl'),
It seams to me that I'm building it the wrong way, is there an instruction?

Here are my steps:
1) I downloaded SDK, mm , sm this way https://wiki.alliedmods.net/Building_sourcemod
2) Placed SteamWorks alongside with sourcemod
3) Downloaded steamworks SDK from this link https://partner.steamgames.com/downl...mworks_sdk.zip
4) Extracted the arhive and renamed sdk to steamworks_sdk
5)
Quote:
cd SteamWorks
mkdir build
cd build
python ../configure.py
ambuild
UPD:
after switching to gcc 5.5 I get this error:
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/sdk/smsdk_ext.cpp:475:33errorexpected initializer before '_GLIBCXX_USE_NOEXCEPT'
 
void operator delete(void *ptr_GLIBCXX_USE_NOEXCEPT 

Last edited by kadet.89; 01-01-2021 at 19:36.
kadet.89 is offline
Send a message via Skype™ to kadet.89
NomisCZ
AlliedModders Donor
Join Date: Mar 2014
Location: Czech_Republic
Old 01-06-2021 , 15:09   Re: [ANY] SteamWorks
Reply With Quote #813

Check out updated AMBuildScript (https://github.com/hexa-core-eu/Stea.../AMBuildScript) and set environment variables CC and CXX to clang.

Try to add '-Wno-delete-non-virtual-dtor' to cxx.cxxflags

HTML Code:
CC=clang CXX=clang python ../configure.py <params ...>

Download compiled extension for Linux/Win/macOS: https://github.com/hexa-core-eu/SteamWorks/releases (SteamWorks 1.49, SM >= 1.10)
Or fork, edit what you want and build on Github (https://github.com/hexa-core-eu/Stea...flows/main.yml).


Quote:
Originally Posted by kadet.89 View Post
I'm trying to build this extension and get 3 such errors:
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/swgchooks.cpp:28:1errordelete called on non-final '__SourceHook_FHCls_ISteamGameCoordinatorSendMessage0::CMyDelegateImpl' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
SH_DECL_HOOK3(ISteamGameCoordinatorSendMessageSH_NOATTRIB0EGCResultsuint32, const void *, uint32);
^
/
home/d/alliedmodders/mmsource-1.10/core/sourcehook/sourcehook.h:1696:3noteexpanded from macro 'SH_DECL_HOOK3'
                
MAKE_DELEG(rettype, (param1 p1param2 p2param3 p3), (p1p2p3)); \
                ^
/
home/d/alliedmodders/mmsource-1.10/core/sourcehook/sourcehook.h:1047:23noteexpanded from macro 'MAKE_DELEG'
                
void DeleteThis() { delete this; } \ 
PHP Code:
/home/d/alliedmodders/sourcemod/public/amtl/amtl/am-string.h:110:28errorno member named 'make_unique' in namespace 'std'
        
auto buffer std::make_unique<char[]>(1); 
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/extension.cpp:74:2errordelete called on non-final 'SteamWorksHTTP' that has virtual functions but non-virtual destructor [-Werror,-Wdelete-non-virtual-dtor]
        
delete this->pSWHTTP
I'm using the latest SDK and clang 3.8. What could be the reason?
Also I had to add these pathes (ambuild couldn't find some headers):

It seams to me that I'm building it the wrong way, is there an instruction?

Here are my steps:
1) I downloaded SDK, mm , sm this way https://wiki.alliedmods.net/Building_sourcemod
2) Placed SteamWorks alongside with sourcemod
3) Downloaded steamworks SDK from this link https://partner.steamgames.com/downl...mworks_sdk.zip
4) Extracted the arhive and renamed sdk to steamworks_sdk
5)


UPD:
after switching to gcc 5.5 I get this error:
PHP Code:
/home/d/alliedmodders/SteamWorks/Extension/sdk/smsdk_ext.cpp:475:33errorexpected initializer before '_GLIBCXX_USE_NOEXCEPT'
 
void operator delete(void *ptr_GLIBCXX_USE_NOEXCEPT 
__________________

Last edited by NomisCZ; 01-06-2021 at 15:18.
NomisCZ is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Location: Serbia
Old 01-24-2021 , 14:36   Re: [ANY] SteamWorks
Reply With Quote #814

I have a steam account with know login/password/steamid e.c.t. is there a way to get the account ISteamUser* interfase inside this extension?
I looked into the SDK specification and found this page: https://partner.steamgames.com/doc/api/ISteamClient
yet it's still not clear how user credetations should be specified to get the right ISteamUser*
All it needs to get the interface is HSteamPipe, which can be obtained with CreateSteamPipe() function. But the function doesn't have any arguments, and it's not clear what steam account the result ISteamUser* interface is for.

Last edited by kadet.89; 01-24-2021 at 14:40.
kadet.89 is offline
Send a message via Skype™ to kadet.89
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 02-01-2021 , 16:07   Re: [ANY] SteamWorks
Reply With Quote #815

SteamWorks will be compiled here again: http://users.alliedmods.net/~kyles/builds/SteamWorks/

Or is it now just his own GitHub? Any solution for getting the latest SteamWorks for Windows version?
paulo_crash is offline
ChampMartini
Member
Join Date: Mar 2021
Old 03-24-2021 , 20:57   Re: [ANY] SteamWorks
Reply With Quote #816

anyone knows how to fix this?
UpdateCheck.smx (SteamWorks Update Check): Required extension "SteamWorks" file("SteamWorks.ext") not running
ChampMartini is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 03-25-2021 , 06:39   Re: [ANY] SteamWorks
Reply With Quote #817

Quote:
Originally Posted by ChampMartini View Post
anyone knows how to fix this?
UpdateCheck.smx (SteamWorks Update Check): Required extension "SteamWorks" file("SteamWorks.ext") not running
Linux version: https://github.com/KyleSanderson/SteamWorks/releases (https://github.com/KyleSanderson/Ste...ackage-lin.tgz)
Windows version: http://users.alliedmods.net/~kyles/builds/SteamWorks/

However, apparently windows is offline through the AlliedModders website;
paulo_crash is offline
NomisCZ
AlliedModders Donor
Join Date: Mar 2014
Location: Czech_Republic
Old 03-25-2021 , 18:50   Re: [ANY] SteamWorks
Reply With Quote #818

For all platforms: https://github.com/hexa-core-eu/SteamWorks/releases
__________________
NomisCZ is offline
paulo_crash
AlliedModders Donor
Join Date: May 2016
Location: Brazil
Old 03-25-2021 , 19:39   Re: [ANY] SteamWorks
Reply With Quote #819

Quote:
Originally Posted by NomisCZ View Post


God, thank you for sharing this resource / fix with mere mortals.
paulo_crash is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 05-04-2021 , 13:32   Re: [ANY] SteamWorks
Reply With Quote #820

My game doesn't work! Nothing works!

Everything points to steamworks crashing after the new CS:GO update.

Below attached a plugin that crashes only after the new update:

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "RumbleFrog, SourceBans++ Dev Team, edit by Eyal282"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <SteamWorks>
#include <smjansson>
#include <sqlitebans>

#undef REQUIRE_PLUGIN
#undef REQUIRE_EXTENSIONS
#tryinclude <autoexecconfig>

#pragma newdecls required

enum
{
	Ban,
	Comms,
	Type_Count,
	Type_Unknown,
};

int EmbedColors[Type_Count] = {
	0xDA1D87, // Ban
	0x4362FA, // Comms
};

char sHostname[256], sHost[64];

ConVar Convars_WebHook[Type_Count];
ConVar Convars_BotName[Type_Count][2];
ConVar Convars_BotImage[Type_Count][2];

public Plugin myinfo =
{
	name = "SQLiteBans Discord Plugin",
	author = PLUGIN_AUTHOR,
	description = "Listens for ban forward and sends it to webhook endpoints",
	version = PLUGIN_VERSION,
	url = "https://sbpp.github.io"
};

public void OnPluginStart()
{
	CreateConVar("sqlite_bans_discord_version", PLUGIN_VERSION, "SBPP Discord Version", FCVAR_REPLICATED | FCVAR_SPONLY | FCVAR_DONTRECORD | FCVAR_NOTIFY);

}

public void OnAllPluginsLoaded()
{
	#if defined _autoexecconfig_included
	
	AutoExecConfig_SetFile("SQLiteBans_Discord");
	
	#endif
	
	Convars_WebHook[Ban] = UC_CreateConVar("sqlite_bans_discord_ban_hook", "https://discord.com/api/webhooks/837021016404262962/IP9ZMDYrCPk7aaoun6MQiPXp9myT7UY3GREK0VEs4Aceuy18iXH9yo6ydN7GqJjC3A96", "Discord web hook endpoint for ban forward", FCVAR_PROTECTED);
	Convars_WebHook[Comms] = UC_CreateConVar("sqlite_bans_discord_comms_hook", "", "Discord web hook endpoint for comms forward. If left empty, the ban endpoint will be used instead", FCVAR_PROTECTED);
	
	Convars_BotName[Ban][0] = UC_CreateConVar("sqlite_bans_discord_ban_name", "SQLite Bans", "Discord bot name for bans", FCVAR_PROTECTED);
	Convars_BotName[Comms][0] = UC_CreateConVar("sqlite_bans_discord_comms_name", "", "Discord bot name for comm bans, if empty, the ban name will be used instead.", FCVAR_PROTECTED);

	Convars_BotImage[Ban][0] = UC_CreateConVar("sqlite_bans_discord_ban_image", "https://wallpapercave.com/wp/AKsyaeQ.jpg", "Discord bot image URL for bans", FCVAR_PROTECTED);
	Convars_BotImage[Comms][0] = UC_CreateConVar("sqlite_bans_discord_comms_image", "", "Discord bot image URL for comm bans. if left empty, the ban image will be used instead.", FCVAR_PROTECTED);
	
	Convars_BotName[Ban][1] = UC_CreateConVar("sqlite_bans_discord_unban_name", "SQLite Bans", "Discord bot name for unbans", FCVAR_PROTECTED);
	Convars_BotName[Comms][1] = UC_CreateConVar("sqlite_bans_discord_uncomms_name", "", "Discord bot name for comm unbans, if empty, the ban name will be used instead.", FCVAR_PROTECTED);

	Convars_BotImage[Ban][1] = UC_CreateConVar("sqlite_bans_discord_unban_image", "https://wallpapercave.com/wp/AKsyaeQ.jpg", "Discord bot image URL for unbans.", FCVAR_PROTECTED);
	Convars_BotImage[Comms][1] = UC_CreateConVar("sqlite_bans_discord_uncomms_image", "", "Discord bot image URL for comm unbans. if left empty, the ban image will be used instead.", FCVAR_PROTECTED);
	
	#if defined _autoexecconfig_included
	
	AutoExecConfig_ExecuteFile();

	AutoExecConfig_CleanFile();
	
	#endif
}
public void OnConfigsExecuted()
{
	FindConVar("hostname").GetString(sHostname, sizeof sHostname);
	
	int ip[4];
	
	SteamWorks_GetPublicIP(ip);
	
	if (SteamWorks_GetPublicIP(ip))
	{
		Format(sHost, sizeof sHost, "%d.%d.%d.%d:%d", ip[0], ip[1], ip[2], ip[3], FindConVar("hostport").IntValue);
	} else
	{
		int iIPB = FindConVar("hostip").IntValue;
		Format(sHost, sizeof sHost, "%d.%d.%d.%d:%d", iIPB >> 24 & 0x000000FF, iIPB >> 16 & 0x000000FF, iIPB >> 8 & 0x000000FF, iIPB & 0x000000FF, FindConVar("hostport").IntValue);
	}
}

public void SQLiteBans_OnBanIdentity_Post(const char AuthId[35], const char Name[64], const char AdminAuthId[35], const char AdminName[64], const char reason[256], int time)
{
	Punish_SendReport(AdminAuthId, AdminName, AuthId, Name, reason, Ban, time);
}

public void SQLiteBans_OnCommPunishIdentity_Post(enPenaltyType PenaltyType, const char AuthId[35], const char Name[64], const char AdminAuthId[35], const char AdminName[64], const char reason[256], int time)
{
	Punish_SendReport(AdminAuthId, AdminName, AuthId, Name, reason, Comms, time, PenaltyType);
}


public void SQLiteBans_OnUnbanIdentity_Post(const char AuthId[35], const char Name[64], const char AdminAuthId[35], const char AdminName[64])
{
	Unpunish_SendReport(AdminAuthId, AdminName, AuthId, Name, Ban);
}

public void SQLiteBans_OnCommUnpunishIdentity_Post(enPenaltyType PenaltyType, const char AuthId[35], const char Name[64], const char AdminAuthId[35], const char AdminName[64])
{
	Unpunish_SendReport(AdminAuthId, AdminName, AuthId, Name, Comms, PenaltyType);
}

void Punish_SendReport(const char AdminAuthId[35], const char AdminName[64], const char AuthId[35], const char Name[64], const char[] sReason, int iType = Ban, int iTime = -1, any extra = 0)
{
	char sBotWebHook[512], sBotName[64], sBotImage[256];
	
	Convars_WebHook[iType].GetString(sBotWebHook, sizeof(sBotWebHook));
	Convars_BotImage[iType][0].GetString(sBotImage, sizeof(sBotImage));
	Convars_BotName[iType][0].GetString(sBotName, sizeof(sBotName));
	
	if(sBotWebHook[0] == EOS)
		Convars_WebHook[Ban].GetString(sBotWebHook, sizeof(sBotWebHook));
		
	if(sBotImage[0] == EOS)
		Convars_BotImage[Ban][0].GetString(sBotImage, sizeof(sBotImage));
		
	if(sBotName[0] == EOS)
		Convars_BotName[Ban][0].GetString(sBotName, sizeof(sBotName));
		
	if(sBotWebHook[0] == EOS)
	{
		LogError("Missing ban hook endpoint");
		return;
	}
	
	else if(sBotName[0] == EOS)
	{
		LogError("Missing ban bot name");
		return;
	}
	
	else if(sBotImage[0] == EOS)
	{
		LogError("Missing ban bot image");
		return;
	}

	char sJson[2048], sBuffer[256];

	Handle jRequest = json_object();

	Handle jEmbeds = json_array();


	Handle jContent = json_object();
	
	json_object_set(jContent, "color", json_integer(GetEmbedColor(iType)));

	Handle jContentAuthor = json_object();

	json_object_set_new(jContentAuthor, "name", json_string(Name));
	
	char steam3[64];
	SteamIDToSteamID3(AuthId, steam3, sizeof(steam3));
	
	Format(sBuffer, sizeof sBuffer, "https://steamcommunity.com/profiles/%s", steam3);
	json_object_set_new(jContentAuthor, "url", json_string(sBuffer));
	json_object_set_new(jContentAuthor, "icon_url", json_string(sBotImage));
	json_object_set_new(jContent, "author", jContentAuthor);

	Handle jContentFooter = json_object();

	Format(sBuffer, sizeof sBuffer, "%s (%s)", sHostname, sHost);
	json_object_set_new(jContentFooter, "text", json_string(sBuffer));
	json_object_set_new(jContentFooter, "icon_url", json_string(sBotImage));
	json_object_set_new(jContent, "footer", jContentFooter);


	Handle jFields = json_array();


	Handle jFieldAuthor = json_object();
	json_object_set_new(jFieldAuthor, "name", json_string("Author"));
	Format(sBuffer, sizeof sBuffer, "%s (%s)", AdminName, AdminAuthId);
	json_object_set_new(jFieldAuthor, "value", json_string(sBuffer));
	json_object_set_new(jFieldAuthor, "inline", json_boolean(true));

	Handle jFieldTarget = json_object();
	json_object_set_new(jFieldTarget, "name", json_string("Target"));
	Format(sBuffer, sizeof sBuffer, "%s (%s)", Name, AuthId);
	json_object_set_new(jFieldTarget, "value", json_string(sBuffer));
	json_object_set_new(jFieldTarget, "inline", json_boolean(true));

	Handle jFieldReason = json_object();
	json_object_set_new(jFieldReason, "name", json_string("Reason"));
	json_object_set_new(jFieldReason, "value", json_string(sReason));

	json_array_append_new(jFields, jFieldAuthor);
	json_array_append_new(jFields, jFieldTarget);

	if (iType == Ban || iType == Comms)
	{
		Handle jFieldDuration = json_object();

		json_object_set_new(jFieldDuration, "name", json_string("Duration"));

		if (iTime > 0)
			Format(sBuffer, sizeof sBuffer, "%d Minutes", iTime);

		else
			Format(sBuffer, sizeof sBuffer, "Permanent");

		json_object_set_new(jFieldDuration, "value", json_string(sBuffer));

		json_array_append_new(jFields, jFieldDuration);
	}
	
	if (iType == Comms)
	{
		Handle jFieldCommType = json_object();
		
		json_object_set_new(jFieldCommType, "name", json_string("Comm Type"));
		
		char cType[32];
		
		PenaltyAliasByType(extra, cType, sizeof cType, false);
		
		cType[0] = CharToUpper(cType[0]);
		
		json_object_set_new(jFieldCommType, "value", json_string(cType));
		
		json_array_append_new(jFields, jFieldCommType);
	}

	json_array_append_new(jFields, jFieldReason);


	json_object_set_new(jContent, "fields", jFields);



	json_array_append_new(jEmbeds, jContent);

	json_object_set_new(jRequest, "username", json_string(sBotName));
	json_object_set_new(jRequest, "avatar_url", json_string(sBotImage));
	json_object_set_new(jRequest, "embeds", jEmbeds);



	json_dump(jRequest, sJson, sizeof sJson, 0, false, false, true);

	#if defined DEBUG
		PrintToServer(sJson);
	#endif

	CloseHandle(jRequest);

	Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, sBotWebHook);

	SteamWorks_SetHTTPRequestContextValue(hRequest, 0, 0);
	SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "payload_json", sJson);
	SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestComplete);

	if (!SteamWorks_SendHTTPRequest(hRequest))
		LogError("HTTP request failed for %s against %s", AdminName, Name);
}


void Unpunish_SendReport(const char AdminAuthId[35], const char AdminName[64], const char AuthId[35], const char Name[64], int iType = Ban, any extra = 0)
{
	char sBotWebHook[512], sBotName[64], sBotImage[256];
	
	Convars_WebHook[iType].GetString(sBotWebHook, sizeof(sBotWebHook));
	Convars_BotImage[iType][1].GetString(sBotImage, sizeof(sBotImage));
	Convars_BotName[iType][1].GetString(sBotName, sizeof(sBotName));
	
	if(sBotWebHook[0] == EOS)
		Convars_WebHook[Ban].GetString(sBotWebHook, sizeof(sBotWebHook));
		
	if(sBotImage[0] == EOS)
		Convars_BotImage[Ban][1].GetString(sBotImage, sizeof(sBotImage));
		
	if(sBotName[0] == EOS)
		Convars_BotName[Ban][1].GetString(sBotName, sizeof(sBotName));
		
	if(sBotWebHook[0] == EOS)
	{
		LogError("Missing ban hook endpoint");
		return;
	}
	
	else if(sBotName[0] == EOS)
	{
		LogError("Missing ban bot name");
		return;
	}
	
	else if(sBotImage[0] == EOS)
	{
		LogError("Missing ban bot image");
		return;
	}

	char sJson[2048], sBuffer[256];

	Handle jRequest = json_object();

	Handle jEmbeds = json_array();


	Handle jContent = json_object();
	
	json_object_set(jContent, "color", json_integer(GetEmbedColor(iType)));

	Handle jContentAuthor = json_object();

	json_object_set_new(jContentAuthor, "name", json_string(Name));
	
	char steam3[64];
	SteamIDToSteamID3(AuthId, steam3, sizeof(steam3));
	
	Format(sBuffer, sizeof sBuffer, "https://steamcommunity.com/profiles/%s", steam3);
	json_object_set_new(jContentAuthor, "url", json_string(sBuffer));
	json_object_set_new(jContentAuthor, "icon_url", json_string(sBotImage));
	json_object_set_new(jContent, "author", jContentAuthor);

	Handle jContentFooter = json_object();

	Format(sBuffer, sizeof sBuffer, "%s (%s)", sHostname, sHost);
	json_object_set_new(jContentFooter, "text", json_string(sBuffer));
	json_object_set_new(jContentFooter, "icon_url", json_string(sBotImage));
	json_object_set_new(jContent, "footer", jContentFooter);


	Handle jFields = json_array();


	Handle jFieldAuthor = json_object();
	json_object_set_new(jFieldAuthor, "name", json_string("Author"));
	Format(sBuffer, sizeof sBuffer, "%s (%s)", AdminName, AdminAuthId);
	json_object_set_new(jFieldAuthor, "value", json_string(sBuffer));
	json_object_set_new(jFieldAuthor, "inline", json_boolean(true));

	Handle jFieldTarget = json_object();
	json_object_set_new(jFieldTarget, "name", json_string("Target"));
	Format(sBuffer, sizeof sBuffer, "%s (%s)", Name, AuthId);
	json_object_set_new(jFieldTarget, "value", json_string(sBuffer));
	json_object_set_new(jFieldTarget, "inline", json_boolean(true));

	json_array_append_new(jFields, jFieldAuthor);
	json_array_append_new(jFields, jFieldTarget);
	
	if (iType == Comms)
	{
		Handle jFieldCommType = json_object();
		
		json_object_set_new(jFieldCommType, "name", json_string("Comm Type"));
		
		char cType[32];
		
		PenaltyAliasByType(extra, cType, sizeof cType, false);
		
		cType[0] = CharToUpper(cType[0]);
		
		json_object_set_new(jFieldCommType, "value", json_string(cType));
		
		json_array_append_new(jFields, jFieldCommType);
	}


	json_object_set_new(jContent, "fields", jFields);



	json_array_append_new(jEmbeds, jContent);

	json_object_set_new(jRequest, "username", json_string(sBotName));
	json_object_set_new(jRequest, "avatar_url", json_string(sBotImage));
	json_object_set_new(jRequest, "embeds", jEmbeds);



	json_dump(jRequest, sJson, sizeof sJson, 0, false, false, true);

	#if defined DEBUG
		PrintToServer(sJson);
	#endif

	CloseHandle(jRequest);

	Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST, sBotWebHook);

	SteamWorks_SetHTTPRequestContextValue(hRequest, 0, 0);
	SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "payload_json", sJson);
	SteamWorks_SetHTTPCallbacks(hRequest, OnHTTPRequestComplete);

	if (!SteamWorks_SendHTTPRequest(hRequest))
		LogError("HTTP request failed for %s against %s", AdminName, Name);
}

public int OnHTTPRequestComplete(Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode)
{
	if (!bRequestSuccessful || eStatusCode != k_EHTTPStatusCode204NoContent)
	{
		LogError("HTTP request failed");

		#if defined DEBUG
			int iSize;

			SteamWorks_GetHTTPResponseBodySize(hRequest, iSize);

			char[] sBody = new char[iSize];

			SteamWorks_GetHTTPResponseBodyData(hRequest, sBody, iSize);

			PrintToServer(sBody);
			PrintToServer("Status Code: %d", eStatusCode);
			PrintToServer("SteamWorks_IsLoaded: %d", SteamWorks_IsLoaded());
		#endif
	}

	CloseHandle(hRequest);
}

int GetEmbedColor(int iType)
{
	if (iType != Type_Unknown)
		return EmbedColors[iType];
	
	return EmbedColors[Ban];
}

stock bool IsValidClient(int iClient, bool bAlive = false)
{
	if (iClient >= 1 &&
	iClient <= MaxClients &&
	IsClientConnected(iClient) &&
	IsClientInGame(iClient) &&
	!IsFakeClient(iClient) &&
	(bAlive == false || IsPlayerAlive(iClient)))
	{
		return true;
	}

	return false;
}

void SteamIDToSteamID3(const char[] authid, char[] steamid3, int len) {
    // STEAM_X:Y:Z
    // W = Z * 2 + Y
    // [U:1:W]
    char buffer[3][32];
    ExplodeString(authid, ":", buffer, sizeof buffer, sizeof buffer[]);
    int w = StringToInt(buffer[2]) * 2 + StringToInt(buffer[1]);
    FormatEx(steamid3, len, "[U:1:%i]", w);
}

#if defined _autoexecconfig_included

stock ConVar UC_CreateConVar(const char[] name, const char[] defaultValue, const char[] description = "", int flags = 0, bool hasMin = false, float min = 0.0, bool hasMax = false, float max = 0.0)
{
	ConVar hndl = AutoExecConfig_CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
	
	if(flags & FCVAR_PROTECTED)
		ServerCommand("sm_cvar protect %s", name);
		
	return hndl;
}

#else

stock ConVar UC_CreateConVar(const char[] name, const char[] defaultValue, const char[] description = "", int flags = 0, bool hasMin = false, float min = 0.0, bool hasMax = false, float max = 0.0)
{
	ConVar hndl = CreateConVar(name, defaultValue, description, flags, hasMin, min, hasMax, max);
	
	if(flags & FCVAR_PROTECTED)
		ServerCommand("sm_cvar protect %s", name);
		
	return hndl;
}
 
#endif
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334

Last edited by eyal282; 05-04-2021 at 13:32.
eyal282 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 08:25.


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