Custom Entities API
DescriptionCreate custom entity on your mapThis API help you create some custom entities for your mod with some presets like models, size, etc.
It's can be used to create gameplay entities, items, props.
Create custom entityJust create entity with custom classname, which registered in CE API
Remove custom entity correctly
PHP Code:
new ceEnt = CE_Create(szClassname, vOrigin);
if (ceEnt) {
dllfunc(DLLFunc_Spawn, ceEnt);
}
API
PHP Code:
CE_Remove(ent);
CE_SPAWNER
PHP Code:
//Base classname for custom entities
#define CE_BASE_CLASSNAME "info_target"
enum CEPreset //Presets
{
CEPreset_None = 0,
CEPreset_Item, //For items
CEPreset_NPC, //For NPC
CEPreset_Prop //For props
};
enum CEFunction
{
CEFunction_Spawn, //Called when entity spawned.
CEFunction_Remove, //Called before entity will be removed.
CEFunction_Picked, //Called when entity picked.
CEFunction_Pickup, //Called when player touch item. Must return PLUGIN_HANDLED if picked.
CEFunction_KVD //Called when new key value obtained
};
/*
* Register entity.
*
* @param szName Name of entity.
* @param modelIndex Precached model index.
* @param vMins Min size of entity.
* @param vMaxs Max size of entity.
* @param fLifeTime Life time of entity.
* @param preset Preset for entity.
*/
native CE_Register
(
const szName[],
modelIndex = 0,
const Float:vMins[3] = {-8.0, -8.0, -8.0},
const Float:vMaxs[3] = {8.0, 8.0, 8.0},
Float:fLifeTime = 0.0,
CEPreset:preset = CEPreset_None
);
/*
* Create entity.
*
* @param szName Name of entity.
* @param vOrigin Spawn origin.
* @param temp Remove entity in next round if true.
* @return Entity index.
*/
native CE_Create(const szName[], const Float:vOrigin[3], bool:temp = true);
/*
* Gets size of entity.
*
* @param szClassname Classname of entity.
* @param vSize Output vector.
*/
native CE_GetSize(const szName[], Float:vMins[3], Float:vMaxs[3]);
/*
* Gets modelindex of entity.
*
* @param szClassname Classname of entity.
* @return Modelindex of entity
*/
native CE_GetModelIndex(const szName[]);
/*
* Remove entity correctly.
*
* @param ent Index of entity.
* @return Result true/false
*/
native bool:CE_Remove(ent);
/*
* Check if entity is associated with current plugin.
*
* @param ent Index of entity.
* @return Result true/false
*/
native bool:CE_CheckAssociation(ent);
/*
* Register new hook for entity.
*
* @param function Function handler
* @param szClassname Classname of entity
* @param szCallback Callback
*/
native CE_RegisterHook(CEFunction:function, const szClassname[], const szCallback[]);
/*
* Get entity handler.
*
* @param szClassname Classname of entity
* @return handle index
*/
native CE_GetHandler(const szClassname[]);
Custom Entity Spawner.
Spawner KVD
- ce_name (string) - Entity to spawn
- delay (float) - Delay before spawn (0.0 - spawn once per round)
- impulse (float) - Max velocity for entity after spawn.
Attached Files



Wyświetl pełny artykuł