Raised This Month: $ Target: $400
 0% 

Flagging an entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bibu
Veteran Member
Join Date: Sep 2010
Old 04-24-2013 , 14:07   Flagging an entity
Reply With Quote #1

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?
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-24-2013 , 15:16   Re: Flagging an entity
Reply With Quote #2

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-24-2013 at 15:17.
ConnorMcLeod is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 04-25-2013 , 12:10   Re: Flagging an entity
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
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 View Post
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 
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.
bibu is offline
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 04-25-2013 , 16:37   Re: Flagging an entity
Reply With Quote #4

I use
PHP Code:
new iEntType[256
and I don't have any error

Last edited by baneado; 04-25-2013 at 16:38.
baneado is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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