Skip to content

Implement RH_SV_SendResources hook#308

Merged
s1lentq merged 2 commits intorehlds:masterfrom
ShadowsAdi:add-svaddresources-hook
May 13, 2024
Merged

Implement RH_SV_SendResources hook#308
s1lentq merged 2 commits intorehlds:masterfrom
ShadowsAdi:add-svaddresources-hook

Conversation

@ShadowsAdi
Copy link
Contributor

@ShadowsAdi ShadowsAdi commented Mar 3, 2024

Useful to create a custom resource list when requested by a client or to allow multiple download url setup.

Example:

/* Sublime AMXX Editor v4.2 */

#include <amxmodx>
#include <reapi>
#include <geoip>

new g_pCvar
new g_szCvar[64]

public plugin_init()
{
	RegisterHookChain(RH_SV_SendResources, "RH_SV_SendResources_Pre")
	RegisterHookChain(RH_SV_SendResources, "RH_SV_SendResources_Post", 1)
}

public plugin_precache()
{
	server_cmd("exec server.cfg")
	server_exec()

	g_pCvar = get_cvar_pointer("sv_downloadurl")
	get_pcvar_string(g_pCvar, g_szCvar, charsmax(g_szCvar))
}

public RH_SV_SendResources_Post()
{
	RequestFrame("SV_SendResFrame")
}

public SV_SendResFrame()
{
	new szCvar[64]
	set_pcvar_string(g_pCvar, g_szCvar)
	get_pcvar_string(g_pCvar, szCvar, charsmax(szCvar))
}

public RH_SV_SendResources_Pre()
{
	new szIP[18], szRez[3], szCvar[64]
	rh_get_net_from(szIP, charsmax(szIP))

	geoip_code2_ex(szIP, szRez)

	if(equali(szRez, "RO"))
	{
		set_pcvar_string(g_pCvar, "test.com")
		get_pcvar_string(g_pCvar, szCvar, charsmax(szCvar))
	}
}

ShadowsAdi and others added 2 commits March 3, 2024 04:00
@s1lentq s1lentq merged commit 6c6ff95 into rehlds:master May 13, 2024
@ShadowsAdi ShadowsAdi deleted the add-svaddresources-hook branch September 9, 2024 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants