AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Cache values for custom ents (https://forums.alliedmods.net/showthread.php?t=221803)

dFF 07-26-2013 14:40

Cache values for custom ents
 
PHP Code:

const MAX_PLAYERS 32
#define MAX_ENTS ( 900 +  MAX_PLAYERS * 15 )
#define ENTS_ARRAY_SIZE ( MAX_ENTS / 32 ) + _:!!( MAX_ENTS % 32 )

new Float:g_fVelocityENTS_ARRAY_SIZE ][ ]

public 
CreateEnts()
{
    new 
iEnt create_entity"info_target" )
    
peviEntpev_velocityg_fVelocityiEnt ] ) // index out of bounds
}

public 
EntsThinkiEnt )
{
    if( 
is_valid_entiEnt ) )
    {
        
PrintVelocityiEnt )
        
        
// set next think .. others
    
}
}

PrintVelocityiEnt )
{
    
server_print"print: %f %f %f"g_fVelocityiEnt ][ ], g_fVelocityiEnt ][ ], g_fVelocityiEnt ][ ] )


I want to cache some values from custom entityes into a global, but i get index out of bounds error.
It's not possible with bits calculation ?

edit:
it's work if i used
PHP Code:

new Float:g_fVelocityMAX_ENTS ][ 

but it's to big big big array .. it's not a way to do this in a better method ?

ConnorMcLeod 07-26-2013 14:58

Re: Cache values for custom ents
 
Just don't cache values, should be ok for performances.

dFF 07-26-2013 15:04

Re: Cache values for custom ents
 
For example: pev_origin
my entityes thinks at very 0.1 second and in EntsThink( iEnt ) it's useless to call everytime at 0.1 pev( iEnt, pev_origin, fOrigin ) so i thinks it's was better to cache some values they change never (only at create entityes).
But anyway, it's not a big problem. Just for my curiosity. :wink:

ConnorMcLeod 07-26-2013 15:17

Re: Cache values for custom ents
 
It's not a problem at all with a 0.1 period.

dFF 07-26-2013 15:20

Re: Cache values for custom ents
 
Okey, thanks. :mrgreen: :bee:


All times are GMT -4. The time now is 06:31.

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