[STOCK] Custom Data Entities

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1090
Gender:
United States of America

[STOCK] Custom Data Entities

Post by Archive-Poster »

Hello again!. This time I come to share this series of functions that I created a while ago for the dynamic handling of data in entities.

_______________________________________

CUSTOM ENTITIES DATA

Q: Do you need to handle a large amount of data associated with entities?.
Q: Tired of always using internal entity data (pev -> iuser1, iuser2, fuser1, vuser1, etc...)? .
Q: Ran out of pevs available to use?.

A: Don't worry, here is the solution. Just use this series of functions/stocks that will make your job much easier. And the best thing is that you can work with a wide variety of data, which will be associated with the entity you want (even players [YES, YOU READ WELL, PLAYERS!]).


• WHAT IS THIS UTILITY

Custom Entities Data (CED) is based on the module of the same name published here, which, as its name suggests, allows you to manage an infinite number of data associated with a specific entity.

For example: I have an entity and I want to store the "state" data. So I would do this:

Code: Select all

CED_SetCell(entity, "state", entity_state) 
And to get it I just do:

Code: Select all

new state
CED_GetCell(entity, "state", state)

print("the entity state is: %d", state) 
It can work with:
CELLS (they can be integers/floats/logical -> int/float/bool)
STRING
ARRAY

• HOW IS IT USED?

It has 8 main stocks for data management:

● Save/update data:

Code: Select all

CED_SetCell
CED_SetString
CED_SetArray 
● Load data

Code: Select all

CED_GetCell
CED_GetString
CED_GetArray


● Clears (deletes) all data saved in the entity

Code: Select all

CED_Clear 
● Same as above, but for all entities; frees the memory used to store the data (MANDATORY TO USE [preference every time the server changes maps and/or where needed])

Code: Select all

CED_Free 
• WHAT DIFFERENCES IT FROM THE MODULE?

I have never seen the source code of the module, but it is known that since it is a (*theory*) module, it is faster when performing operations (although the times we are living in, your PC will not hang for using this....)

But above all, the named module does not work well, so I found myself in need of making this stock.

• CODE

Inside the include there are several examples for handling data. I will also leave some examples
Attachments
custom_entities_data.inc.zip
(3.59 KiB) Downloaded 3 times

Who is online

Users browsing this forum: No registered users and 0 guests