Idk if anyone needs this, but I did anyway.
Basically not all ents are useable, sure you can hook use on them, but it wont register when a player hits his use key on it. You can change this however by messing a bit with the function objectcaps.
What is objectcaps?
Code: Select all
virtual int ObjectCaps( void ) { return FCAP_ACROSS_TRANSITION; } From the sdk:
Code: Select all
// These are caps bits to indicate what an object's capabilities (currently used for save/restore and level transitions)
#define FCAP_CUSTOMSAVE 0x00000001
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player
#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player
#define FCAP_ONOFF_USE 0x00000020 // can be used by the player
#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains)
#define FCAP_MASTER 0x00000080 // Can be used to "master" other entities (like multisource)Code: Select all
#include <amxmodx>
#include <hamsandwich>
#define FCAP_CUSTOMSAVE 0x00000001
#define FCAP_ACROSS_TRANSITION 0x00000002 // should transfer between transitions
#define FCAP_MUST_SPAWN 0x00000004 // Spawn after restore
#define FCAP_DONT_SAVE 0x80000000 // Don't save this
#define FCAP_IMPULSE_USE 0x00000008 // can be used by the player
#define FCAP_CONTINUOUS_USE 0x00000010 // can be used by the player
#define FCAP_ONOFF_USE 0x00000020 // can be used by the player
#define FCAP_DIRECTIONAL_USE 0x00000040 // Player sends +/- 1 when using (currently only tracktrains)
#define FCAP_MASTER 0x00000080
public plugin_init()
{
RegisterHam(Ham_ObjectCaps,"info_target","OnObjectCaps")
RegisterHam(Ham_Use,"info_target","OnUse")
}
public OnObjectCaps()
{
SetHamReturnInteger(FCAP_IMPULSE_USE)
return HAM_OVERRIDE
}
public OnUse(this, idcaller)
{
client_print(idcaller,print_chat,"Use!")
} 