Skocz do zawartości

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

[API] Custom Entities


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
Brak odpowiedzi do tego tematu

#1 Adminek AMXX.PL

    Admin :)

  • Bot

Reputacja: 156
Profesjonalista

  • Postów:7 490
  • Lokalizacja:AMXX.PL
Offline

Napisano 03.11.2016 13:18




Custom Entities API

Description

This 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 entity on your map

Just create entity with custom classname, which registered in CE API

Create custom entity


PHP Code:


new ceEnt = CE_Create(szClassname, vOrigin);
if (
ceEnt) {
dllfunc(DLLFunc_Spawn, ceEnt);
}

Remove custom entity correctly


PHP Code:


CE_Remove(ent);

API


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[]);

CE_SPAWNER

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 Dołączona grafikaGet Plugin or Get Source (api_custom_entities.sma - 14.3 KB) Dołączona grafikaGet Plugin or Get Source (entity_ce_spawner.sma - 4.5 KB) Dołączona grafikaapi_custom_entities.inc (2.5 KB)

Wyświetl pełny artykuł




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych