mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-02-04 09:40:45 +03:00
a445e806ea
- The logic around CS_OnBuy forward has been simplified. Since there is no way to have a consistent way to hook/block for all items, the new logic is to have as less as possible code, especially in blocking mode where we want to avoid to do extra stuffs (e.g blocking sound, event, etc). * All guns + shield -> CanBuyThis() * Nvgs and Fefuser only -> CanPlayerBuy() * The others items -> GiveNamedItem() + AddAccount() * Ammos -> -> BuyGunAmmo() + GiveNamedItem() + AddAccount() - Fixed missing buyzone check when alias from console are used (CS_OnBUy* were incorrectly fired). - Fixed an infinite loop when buying of ammos are blocked. Sorted by hooking BuyGunAmmo(). - Fixed blocking mode for some items. Some game behaviors were not blocked (e.g. weapon drop). - Fixed forwards being triggered even though errors were found. Detours are now a destroyed and associated variables resetted when necessary. Toggling forwards state is now based on detours state. - Moved things in its own functions (game functions to execute, class members retrieval) - Renamed CommandAliases -> ItemInfos (more generic)
107 lines
2.2 KiB
C++
107 lines
2.2 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
|
|
//
|
|
|
|
#ifndef _CSTRIKE_WEAPONS_INFOS_H_
|
|
#define _CSTRIKE_WEAPONS_INFOS_H_
|
|
|
|
#include <amxxmodule.h>
|
|
#include "CstrikeDatas.h"
|
|
#include <ITextParsers.h>
|
|
#include <amtl/am-string.h>
|
|
#include <sm_stringhashmap.h>
|
|
|
|
struct AliasInfo
|
|
{
|
|
AliasInfo()
|
|
{
|
|
clear();
|
|
}
|
|
|
|
void clear()
|
|
{
|
|
itemid = CSI_NONE;
|
|
classid = CS_WEAPONCLASS_NONE;
|
|
}
|
|
|
|
int itemid;
|
|
int classid;
|
|
ke::AString classname;
|
|
};
|
|
|
|
enum class Equipments
|
|
{
|
|
None,
|
|
Vest,
|
|
Vesthelm,
|
|
Flashbang,
|
|
HEGrenade,
|
|
SmokeGrenade,
|
|
Nvg,
|
|
Defuser,
|
|
Count
|
|
};
|
|
|
|
class CsItemInfo : public ITextListener_SMC
|
|
{
|
|
public:
|
|
|
|
CsItemInfo();
|
|
virtual ~CsItemInfo();
|
|
|
|
public:
|
|
|
|
void Clear();
|
|
bool HasConfigError();
|
|
|
|
public:
|
|
|
|
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name) override;
|
|
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value) override;
|
|
SMCResult ReadSMC_LeavingSection(const SMCStates *states) override;
|
|
void ReadSMC_ParseEnd(bool halted, bool failed) override;
|
|
|
|
public:
|
|
|
|
bool GetAliasInfos(const char *alias, AliasInfo *info);
|
|
bool GetAliasInfosFromBuy(const char *alias, AliasInfo *info);
|
|
bool GetAliasInfosFromName(const char *classname, AliasInfo *info);
|
|
|
|
CsWeaponClassType WeaponIdToClass(int id);
|
|
|
|
int GetItemPrice(int id);
|
|
|
|
private: // Retrieved datas
|
|
|
|
typedef StringHashMap<AliasInfo> AliasMap;
|
|
|
|
AliasMap m_CommonAliasesList;
|
|
AliasMap m_WeaponAliasesList;
|
|
AliasMap m_BuyAliasesList;
|
|
|
|
CsWeaponClassType m_WeaponIdToClass[CSI_MAX_COUNT];
|
|
|
|
private: // Config parsing
|
|
|
|
int m_ParseState;
|
|
AliasMap* m_List;
|
|
ke::AString m_Alias;
|
|
AliasInfo m_AliasInfo;
|
|
bool m_ListsRetrievedFromConfig;
|
|
int m_EquipmentsPrice[static_cast<size_t>(Equipments::Count)];
|
|
};
|
|
|
|
extern char WeaponNameList[MAX_WEAPONS][64];
|
|
extern CsItemInfo ItemsManager;
|
|
|
|
#endif // _CSTRIKE_WEAPONS_INFOS_H_
|