AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Flagging an entity (https://forums.alliedmods.net/showthread.php?t=214232)

bibu 04-24-2013 14:07

Flagging an entity
 
I try to set some values according to my entites:

PHP Code:

new iEntType[33]

// getting [Run time error 4: index out of bounds] if I set values to it
//to set:

iEntType[iEnt] = 1

//or:

iEntType[iEnt] = 2

// and to check:

switch(iEntSoundType[iEnt])
{
       case 
1:
       {
       }
       case 
2:
       {
       }


Would this only work with pev_iuser 1, 2, 3 or 4?

ConnorMcLeod 04-24-2013 15:16

Re: Flagging an entity
 
How many types you have ?

If it is only bools :
PHP Code:

#define SetEntBits(%1,%2)    %1[%2>>5] |=  1<<(%2 & 31)
#define ClearEntBits(%1,%2)    %1[%2>>5] &= ~( 1 << (%2 & 31) )
#define GetEntBits(%1,%2)    %1[%2>>5] &   1<<(%2 & 31)

new g_iYellowEntities[64// 64 * 32 allows 2048 ent to be flagged as 0 or 1

// In macros, %1 stands for g_iYellowEntities, %2 for ent index

// mark entity as yellow :

SetEntBits(g_iYellowEntitiesent

But if you have few types, less than 255, you can do :

PHP Code:

new g_cEntityType[2048 char// this array size is 512 cell array (2048 / 4)

// then you use

g_cEntityTypeent } = Type // where type is a byte 0-255, so you can have 255 types 


On default servers, max entity num is now 1800.


Problem using pev_*** is that other plugins could alter it.


Also, you are theorical and abstract, depending of what you exactly need to do, there might be better solutions.

bibu 04-25-2013 12:10

Re: Flagging an entity
 
Quote:

Originally Posted by ConnorMcLeod (Post 1939136)
How many types you have ?

Right now just 3, but I might someday have more (max. 30). And also bools would be useless in this case.

Quote:

Originally Posted by ConnorMcLeod (Post 1939136)
Also, you are theorical and abstract, depending of what you exactly need to do, there might be better solutions.

I create an object (info_target) with a classname and set a different message for these objects, if they touch a player. That's why I tried to use something like that.

Btw, your code worked just fine, but I would like to understand how it really works and for what the numbers stay there. That would be these:

PHP Code:

new g_cEntityType[2048 char// this array size is 512 cell array (2048 / 4)

// why {ent}, and not (ent) or [ent] ?
g_cEntityTypeent } = Type 


baneado 04-25-2013 16:37

Re: Flagging an entity
 
I use
PHP Code:

new iEntType[256

and I don't have any error


All times are GMT -4. The time now is 10:54.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.