Skip to content

Commit

Permalink
Added hook CBasePlayer::HasRestrictItem
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jun 20, 2016
1 parent af1a542 commit 272b2fc
Show file tree
Hide file tree
Showing 14 changed files with 180 additions and 129 deletions.
66 changes: 55 additions & 11 deletions reapi/extra/amxmodx/scripting/include/cssdk_const.inc
Expand Up @@ -682,17 +682,6 @@ enum ArmouryItemPack
ARMOURY_SMOKEGRENADE
};

enum BuyItemID
{
BUY_ITEM_VEST = 1,
BUY_ITEM_VESTHELM,
BUY_ITEM_FLASHGREN,
BUY_ITEM_HEGREN,
BUY_ITEM_SMOKEGREN,
BUY_ITEM_NVG,
BUY_ITEM_DEFUSEKIT
};

enum RewardType
{
RT_NONE,
Expand Down Expand Up @@ -1093,3 +1082,58 @@ enum RewardRules
RR_TOOK_HOSTAGE,
RR_END
};

enum ItemRestType
{
ITEM_TYPE_BUYING, // when a player buying items
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
ITEM_TYPE_EQUIPPED // when a entity game_player_equip to player gives item
};

// constant items
enum ItemID
{
ITEM_NONE = -1,
ITEM_SHIELDGUN,
ITEM_P228,
ITEM_GLOCK,
ITEM_SCOUT,
ITEM_HEGRENADE,
ITEM_XM1014,
ITEM_C4,
ITEM_MAC10,
ITEM_AUG,
ITEM_SMOKEGRENADE,
ITEM_ELITE,
ITEM_FIVESEVEN,
ITEM_UMP45,
ITEM_SG550,
ITEM_GALIL,
ITEM_FAMAS,
ITEM_USP,
ITEM_GLOCK18,
ITEM_AWP,
ITEM_MP5N,
ITEM_M249,
ITEM_M3,
ITEM_M4A1,
ITEM_TMP,
ITEM_G3SG1,
ITEM_FLASHBANG,
ITEM_DEAGLE,
ITEM_SG552,
ITEM_AK47,
ITEM_KNIFE,
ITEM_P90,
ITEM_NVG,
ITEM_DEFUSEKIT,
ITEM_KEVLAR,
ITEM_ASSAULT,
ITEM_LONGJUMP,
ITEM_SODACAN,
ITEM_HEALTHKIT,
ITEM_ANTIDOTE,
ITEM_SECURITY,
ITEM_BATTERY,
ITEM_SUIT
};
27 changes: 11 additions & 16 deletions reapi/extra/amxmodx/scripting/include/reapi_gamedll_const.inc
Expand Up @@ -158,12 +158,6 @@ enum GamedllFunc
*/
RG_RoundEnd,

/*
* Description: -
* Params: (const index, const WeaponIdType:iWeapon)
*/
RG_CanBuyThis,

/*
* Description: -
* Params: (const PlayerMove:ppmove, const server)
Expand Down Expand Up @@ -198,13 +192,7 @@ enum GamedllFunc
* Description: -
* Params: (const index, VGUIMenu:menuType, const bitsSlots, szOldMenu[], bool:bForceOldMenu)
*/
RG_ShowVGUIMenu,

/*
* Description: -
* Params: (const index, BuyItemID:item)
*/
RG_CanBuyThisItem
RG_ShowVGUIMenu
};

enum GamedllFunc_CBaseAnimating
Expand Down Expand Up @@ -408,7 +396,14 @@ enum GamedllFunc_CBasePlayer
* Description: -
* Params: (const this, const pszItemName[])
*/
RG_CBasePlayer_DropPlayerItem
RG_CBasePlayer_DropPlayerItem,

/*
* Description: -
* Params: (const this, ItemID:item, ItemRestType:type)
*/
RG_CBasePlayer_HasRestrictItem

};

enum GamedllFunc_CSGameRules
Expand Down Expand Up @@ -1730,7 +1725,7 @@ enum CBasePlayer_Members

/*
* Description: -
* Member type: int
* Member type: enum ArmorType
* Get params: get_member(index, member);
* Set params: set_member(index, member, value);
*/
Expand Down Expand Up @@ -4239,7 +4234,7 @@ enum CArmoury_Members
{
/*
* Description: -
* Member type: int (or enum's ArmouryItemPack)
* Member type: enum ArmouryItemPack
* Get params: ArmouryItemPack:get_member(index, member);
* Set params: set_member(index, member, ArmouryItemPack:value);
*/
Expand Down
11 changes: 0 additions & 11 deletions reapi/include/cssdk/dlls/client.h
Expand Up @@ -53,17 +53,6 @@ enum BuyItemMenuSlot
MENU_SLOT_ITEM_SHIELD,
};

enum BuyItemID
{
BUY_ITEM_VEST = 1,
BUY_ITEM_VESTHELM,
BUY_ITEM_FLASHGREN,
BUY_ITEM_HEGREN,
BUY_ITEM_SMOKEGREN,
BUY_ITEM_NVG,
BUY_ITEM_DEFUSEKIT
};

#define CS_NUM_SKIN 4
#define CZ_NUM_SKIN 5

Expand Down
64 changes: 54 additions & 10 deletions reapi/include/cssdk/dlls/items.h
Expand Up @@ -27,30 +27,74 @@
*/
#pragma once

enum ItemRestType
{
ITEM_TYPE_BUYING, // when a player buying items
ITEM_TYPE_TOUCHED, // when the player touches with a weaponbox or armoury_entity
ITEM_TYPE_EQUIPPED // when a entity game_player_equip to player gives item
};

// constant items
#define ITEM_HEALTHKIT 1
#define ITEM_ANTIDOTE 2
#define ITEM_SECURITY 3
#define ITEM_BATTERY 4
#define ITEM_SUIT 5
enum ItemID
{
ITEM_NONE = -1,
ITEM_SHIELDGUN,
ITEM_P228,
ITEM_GLOCK,
ITEM_SCOUT,
ITEM_HEGRENADE,
ITEM_XM1014,
ITEM_C4,
ITEM_MAC10,
ITEM_AUG,
ITEM_SMOKEGRENADE,
ITEM_ELITE,
ITEM_FIVESEVEN,
ITEM_UMP45,
ITEM_SG550,
ITEM_GALIL,
ITEM_FAMAS,
ITEM_USP,
ITEM_GLOCK18,
ITEM_AWP,
ITEM_MP5N,
ITEM_M249,
ITEM_M3,
ITEM_M4A1,
ITEM_TMP,
ITEM_G3SG1,
ITEM_FLASHBANG,
ITEM_DEAGLE,
ITEM_SG552,
ITEM_AK47,
ITEM_KNIFE,
ITEM_P90,
ITEM_NVG,
ITEM_DEFUSEKIT,
ITEM_KEVLAR,
ITEM_ASSAULT,
ITEM_LONGJUMP,
ITEM_SODACAN,
ITEM_HEALTHKIT,
ITEM_ANTIDOTE,
ITEM_SECURITY,
ITEM_BATTERY,
ITEM_SUIT
};

class CItem: public CBaseEntity {
public:
virtual void Spawn() = 0;
virtual CBaseEntity *Respawn() = 0;
virtual BOOL MyTouch(CBasePlayer *pPlayer) = 0;

public:
void EXPORT ItemTouch(CBaseEntity *pOther) = 0;
void EXPORT Materialize() = 0;
};

class CWorldItem: public CBaseEntity {
public:
virtual void Spawn() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
public:
int m_iType;
ItemID m_iType;
};

class CItemSuit: public CItem {
Expand Down
4 changes: 2 additions & 2 deletions reapi/include/cssdk/dlls/player.h
Expand Up @@ -243,7 +243,7 @@ struct RebuyStruct
int m_smokeGrenade;
int m_defuser;
int m_nightVision;
int m_armor;
ArmorType m_armor;
};

enum ThrowDirection
Expand Down Expand Up @@ -375,7 +375,7 @@ class CBasePlayer: public CBaseMonster {
int m_iLastZoom;
bool m_bResumeZoom;
float m_flEjectBrass;
int m_iKevlar;
ArmorType m_iKevlar;
bool m_bNotKilled;
TeamName m_iTeam;
int m_iAccount;
Expand Down
29 changes: 12 additions & 17 deletions reapi/include/cssdk/dlls/regamedll_api.h
Expand Up @@ -33,8 +33,9 @@
#include "player.h"
#include "gamerules.h"
#include "client.h"
#include "items.h"

#define REGAMEDLL_API_VERSION_MAJOR 3
#define REGAMEDLL_API_VERSION_MAJOR 4
#define REGAMEDLL_API_VERSION_MINOR 1

// CBasePlayer::Spawn hook
Expand Down Expand Up @@ -157,6 +158,14 @@ typedef IVoidHookChainRegistryClass<class CBasePlayer, char *, char *> IReGameHo
typedef IVoidHookChainClass<class CBasePlayer, char *, char *> IReGameHook_CBasePlayer_SetClientUserInfoName;
typedef IVoidHookChainRegistryClass<class CBasePlayer, char *, char *> IReGameHookRegistry_CBasePlayer_SetClientUserInfoName;

// CBasePlayer::HasRestrictItem hook
typedef IHookChainClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHook_CBasePlayer_HasRestrictItem;
typedef IHookChainRegistryClass<bool, class CBasePlayer, ItemID, ItemRestType> IReGameHookRegistry_CBasePlayer_HasRestrictItem;

// CBasePlayer::DropPlayerItem hook
typedef IVoidHookChainClass<class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropPlayerItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropPlayerItem;

// CBaseAnimating::ResetSequenceInfo hook
typedef IVoidHookChainClass<class CBaseAnimating> IReGameHook_CBaseAnimating_ResetSequenceInfo;
typedef IVoidHookChainRegistryClass<class CBaseAnimating> IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo;
Expand All @@ -177,10 +186,6 @@ typedef IVoidHookChainRegistry<class CBasePlayer *, struct entvars_s *, struct e
typedef IHookChain<bool, int, ScenarioEventEndRound, float> IReGameHook_RoundEnd;
typedef IHookChainRegistry<bool, int, ScenarioEventEndRound, float> IReGameHookRegistry_RoundEnd;

// CanBuyThis hook
typedef IHookChain<bool, class CBasePlayer *, int> IReGameHook_CanBuyThis;
typedef IHookChainRegistry<bool, class CBasePlayer *, int> IReGameHookRegistry_CanBuyThis;

// InstallGameRules hook
typedef IHookChain<class CGameRules *> IReGameHook_InstallGameRules;
typedef IHookChainRegistry<class CGameRules *> IReGameHookRegistry_InstallGameRules;
Expand Down Expand Up @@ -301,14 +306,6 @@ typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_GoToIntermissio
typedef IVoidHookChain<> IReGameHook_CSGameRules_BalanceTeams;
typedef IVoidHookChainRegistry<> IReGameHookRegistry_CSGameRules_BalanceTeams;

// CanBuyThisItem hook
typedef IHookChain<bool, class CBasePlayer *, BuyItemID> IReGameHook_CanBuyThisItem;
typedef IHookChainRegistry<bool, class CBasePlayer *, BuyItemID> IReGameHookRegistry_CanBuyThisItem;

// CBasePlayer::DropPlayerItem hook
typedef IVoidHookChainClass<class CBasePlayer, const char *> IReGameHook_CBasePlayer_DropPlayerItem;
typedef IVoidHookChainRegistryClass<class CBasePlayer, const char *> IReGameHookRegistry_CBasePlayer_DropPlayerItem;

class IReGameHookchains {
public:
virtual ~IReGameHookchains() {}
Expand Down Expand Up @@ -344,13 +341,14 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0;
virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0;
virtual IReGameHookRegistry_CBasePlayer_HasRestrictItem* CBasePlayer_HasRestrictItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0;
virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0;

virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0;
virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0;
virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0;
virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0;
virtual IReGameHookRegistry_CanBuyThis* CanBuyThis() = 0;
virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0;
virtual IReGameHookRegistry_PM_Init* PM_Init() = 0;
virtual IReGameHookRegistry_PM_Move* PM_Move() = 0;
Expand Down Expand Up @@ -382,9 +380,6 @@ class IReGameHookchains {
virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0;
virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0;
virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0;

virtual IReGameHookRegistry_CanBuyThisItem* CanBuyThisItem() = 0;
virtual IReGameHookRegistry_CBasePlayer_DropPlayerItem* CBasePlayer_DropPlayerItem() = 0;
};

struct ReGameFuncs_t {
Expand Down
5 changes: 2 additions & 3 deletions reapi/include/cssdk/dlls/weapons.h
Expand Up @@ -92,8 +92,7 @@ enum ArmouryItemPack
ARMOURY_HEGRENADE,
ARMOURY_KEVLAR,
ARMOURY_ASSAULT,
ARMOURY_SMOKEGRENADE,
ARMOURY_END
ARMOURY_SMOKEGRENADE
};

struct ItemInfo
Expand Down Expand Up @@ -131,7 +130,7 @@ class CArmoury: public CBaseEntity {
virtual void Restart() = 0;
virtual void KeyValue(KeyValueData *pkvd) = 0;
public:
int m_iItem;
ArmouryItemPack m_iItem;
int m_iCount;
int m_iInitialCount;
bool m_bAlreadyCounted;
Expand Down

0 comments on commit 272b2fc

Please sign in to comment.