mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-27 22:28:05 +03:00
e87976bc09
This is actually not possible to have a proper system to allow this. This is two majors problems: - The item price text can't be changed, whatever old and VGUI menu (it's either harcoded in config file or in client binary) - Once you open VGUI menu, to know if user has enough money to select an item, client relies on the current HUD money value, this means, since we can't directly changed price, before opening the menu, money needs to be somehow faked and restored once closed. It's awful. Overall it can't work properly, and at the end current forward doesn't make sense. If an author wanted to have its own prices, the only only way would to force players to use old menu, then overwriting the whole buy menu, so you would be able to display what you want exactly.
108 lines
3.0 KiB
C++
108 lines
3.0 KiB
C++
// vim: set ts=4 sw=4 tw=99 noet:
|
|
//
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
//
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
//
|
|
// Counter-Strike Module
|
|
//
|
|
|
|
#include "amxxmodule.h"
|
|
#include "CstrikeUtils.h"
|
|
#include "CstrikeHacks.h"
|
|
#include <IGameConfigs.h>
|
|
|
|
IGameConfig *MainConfig;
|
|
IGameConfig *CommonConfig;
|
|
IGameConfigManager *ConfigManager;
|
|
|
|
HLTypeConversion TypeConversion;
|
|
|
|
int AmxxCheckGame(const char *game)
|
|
{
|
|
if (strcasecmp(game, "cstrike") == 0 ||
|
|
strcasecmp(game, "czero") == 0)
|
|
{
|
|
return AMXX_GAME_OK;
|
|
}
|
|
return AMXX_GAME_BAD;
|
|
}
|
|
|
|
void OnAmxxAttach()
|
|
{
|
|
MF_AddNatives(CstrikeNatives);
|
|
|
|
ConfigManager = MF_GetConfigManager();
|
|
|
|
char error[256];
|
|
error[0] = '\0';
|
|
|
|
ConfigManager->AddUserConfigHook("CommandsAliases", &ItemsManager);
|
|
|
|
if (!ConfigManager->LoadGameConfigFile("modules.games", &MainConfig, error, sizeof(error)) && error[0] != '\0')
|
|
{
|
|
MF_Log("Could not read module.games gamedata: %s", error);
|
|
return;
|
|
}
|
|
|
|
error[0] = '\0';
|
|
|
|
if (!ConfigManager->LoadGameConfigFile("common.games", &CommonConfig, error, sizeof(error)) && error[0] != '\0')
|
|
{
|
|
MF_Log("Could not read common.games gamedata: %s", error);
|
|
return;
|
|
}
|
|
|
|
InitializeHacks();
|
|
}
|
|
|
|
void OnPluginsLoaded()
|
|
{
|
|
ForwardInternalCommand = MF_RegisterForward("CS_InternalCommand", ET_STOP, FP_CELL, FP_STRING, FP_DONE);
|
|
ForwardOnBuy = MF_RegisterForward("CS_OnBuy" , ET_STOP, FP_CELL, FP_CELL, FP_DONE);
|
|
ForwardOnBuyAttempt = MF_RegisterForward("CS_OnBuyAttempt" , ET_STOP, FP_CELL, FP_CELL, FP_DONE);
|
|
|
|
// Checking whether such public forwards are used in plugins.
|
|
// Resetting variable to -1 to avoid running unnecessary code in ClientCommand.
|
|
if (!UTIL_CheckForPublic("CS_InternalCommand")) { ForwardInternalCommand = -1; }
|
|
if (!UTIL_CheckForPublic("CS_OnBuy")) { ForwardOnBuy = -1; }
|
|
if (!UTIL_CheckForPublic("CS_OnBuyAttempt")) { ForwardOnBuyAttempt = -1; }
|
|
|
|
// And enable/disable detours when necessary.
|
|
ToggleDetour_ClientCommands(ForwardInternalCommand != -1 || ForwardOnBuy != -1 || ForwardOnBuyAttempt != -1);
|
|
ToggleDetour_BuyCommands(ForwardOnBuy != -1);
|
|
|
|
// Search pev/vtable offset automatically.
|
|
TypeConversion.init();
|
|
|
|
// Used with model natives, enabled on demand.
|
|
g_pengfuncsTable->pfnSetClientKeyValue = nullptr;
|
|
g_pFunctionTable->pfnClientUserInfoChanged = nullptr;
|
|
g_pFunctionTable->pfnStartFrame = nullptr;
|
|
}
|
|
|
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
|
{
|
|
// Used to catch WeaponList message at map change.
|
|
EnableMessageHooks();
|
|
}
|
|
|
|
void OnServerActivate_Post(edict_t *pEdictList, int edictCount, int clientMax)
|
|
{
|
|
DisableMessageHooks();
|
|
}
|
|
|
|
void OnAmxxDetach()
|
|
{
|
|
ConfigManager->RemoveUserConfigHook("CommandsAliases", &ItemsManager);
|
|
|
|
ConfigManager->CloseGameConfigFile(MainConfig);
|
|
ConfigManager->CloseGameConfigFile(CommonConfig);
|
|
|
|
ShutdownHacks();
|
|
}
|