AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Invalid cellvector handle provided (https://forums.alliedmods.net/showthread.php?t=252768)

bLacK-bLooD 12-09-2014 05:26

Invalid cellvector handle provided
 
Hi guys, this is what i get in my console once i start my server with the plugin. Basically it's a snow plugin that generates .spr's at a random location. However i believe that the locations are screwed up. This is the error, and it goes on and on.

Code:

L 12/08/2014 - 21:20:30: Invalid cellvector handle provided (6:1220087467:0)
L 12/08/2014 - 21:20:30: [AMXX] Displaying debug trace (plugin "snow_plugin.amxx")
L 12/08/2014 - 21:20:30: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 12/08/2014 - 21:20:30: [AMXX]    [0] snow_plugin.sma::fwd_MagicEntityThink (line 117)
L 12/08/2014 - 21:20:33: Invalid cellvector handle provided (6:1427720619:0)
L 12/08/2014 - 21:20:33: [AMXX] Displaying debug trace (plugin "snow_plugin.amxx")
L 12/08/2014 - 21:20:33: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 12/08/2014 - 21:20:33: [AMXX]    [0] snow_plugin.sma::fwd_MagicEntityThink (line 117)
L 12/08/2014 - 21:20:36: Invalid cellvector handle provided (6:2089803835:0)
L 12/08/2014 - 21:20:36: [AMXX] Displaying debug trace (plugin "snow_plugin.amxx")
L 12/08/2014 - 21:20:36: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 12/08/2014 - 21:20:36: [AMXX]    [0] snow_plugin.sma::fwd_MagicEntityThink (line 117)

This is the code, i highlighted the line 117 to make it easier for you guys to see it in the code :

PHP Code:

#include < amxmodx >
#include < fakemeta >
#include < engine >
#include < xs >


new const
    
PLUGIN_NAME[ ]         = "Realistic Snow",
    
PLUGIN_VERSION[ ]     = "0.4.2b";

#define SS_VERSION    "1.0"
#define SS_MIN_DISTANCE    250.0
#define SS_MAX_LOOPS    100000

new Array:g_vecSsOrigins;
new Array:
g_vecSsSpawns;
new Array:
g_vecSsUsed;
new 
Float:g_flSsMinDist;
new 
g_iSsTime;

new const 
g_szStarts[][] =
{
    
"info_player_start",
    
"info_player_deathmatch"
};

new const 
Float:g_flOffsets[] =
{
    
3500.0,
    
3500.0,
    
1500.0
};

new 
g_iCvarSnowType;

new 
g_iSprite;

new Array:
g_vecOrigins;
new 
g_iOrigins 0;

new 
g_iMagicEntity;
    
public 
plugin_precache( )
{    
    
register_pluginPLUGIN_NAMEPLUGIN_VERSION"Askhanar" );    

    
g_iCvarSnowType register_cvar"rs_type""2" );
        
    
g_iSprite precache_model"sprites/snow1.spr" );
}
                
public 
plugin_init( )
{
    
    
remove_entity_name"env_fog" );
    
remove_entity_name"env_rain" );
    
remove_entity_name"env_snow" );
    
    
g_vecOrigins ArrayCreate3);
    
SsInit200.0 );
    
SsScan( );
    
SsDump( );
    
    
CreateEntity:
    
    new 
iEnt;
    
iEnt  engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
    if( !
pev_validiEnt ) || !iEnt )
        goto 
CreateEntity;
    
    
set_peviEntpev_classname"Askhanar's_MagicEntity" );
    
set_peviEntpev_nextthinkget_gametime(  ) + 1.0 );
    
    
register_forwardFM_Think"fwd_MagicEntityThink" );
    
g_iMagicEntity iEnt;
    
    
    
}

public 
fwd_MagicEntityThinkiEnt )
{
    
set_peviEntpev_nextthinkget_gametime( ) + 3.1 );
    
    static 
iSnowType;
    
iSnowType clampget_pcvar_numg_iCvarSnowType ), 0);

    if( 
iEnt != g_iMagicEntity || !pev_validiEnt ) || !iSnowType )
        return 
FMRES_IGNORED;
        
        
        
    static 
Float:fOrigin], iLocationsiCount;
    switch( 
iSnowType )
    {
        case 
1:
        {
            
iCount 3;
            
iLocations 20;
        }
        case 
2:
        {
            
iCount 5;
            
iLocations 30;
        }
        case 
3:
        {
            
iCount 10;
            
iLocations 45;
        }
    }
    
    while( 
iLocations )
    {
        
ArrayGetArrayg_vecOriginsrandomg_iOrigins ), fOrigin ); //Line 117, where the error occurs.
        
MakeSnowfOriging_iSpriteiCount8random_num510 ), 5030 );
        
iLocations--;
        
    }
    
    return 
FMRES_IGNORED;
}

MakeSnowFloat:fOrigin], iSpriteIdiCountiLifeiScaleiVelocityiRandomness )
{
    
engfuncEngFunc_MessageBeginMSG_BROADCASTSVC_TEMPENTITYfOrigin);
    
write_byteTE_SPRITETRAIL ); // TE ID
    
engfuncEngFunc_WriteCoordfOrigin] ); // x axis
    
engfuncEngFunc_WriteCoordfOrigin] ); // y axis
    
engfuncEngFunc_WriteCoordfOrigin] + 40 ); // z axis
    
engfuncEngFunc_WriteCoordfOrigin] ); // x axis
    
engfuncEngFunc_WriteCoordfOrigin] ); // y axis
    
engfuncEngFunc_WriteCoordfOrigin] ); // z axis
    
write_shortiSpriteId ); // Sprite Index
    
write_byteiCount ); // Count
    
write_byteiLife ); // Life
    
write_byteiScale ); // Scale
    
write_byteiVelocity  ); // Velocity Along Vector
    
write_byteiRandomness ); // Rendomness of Velocity
    
message_end( );
}


stock Get_Sky_Origin( const Float:vecTarget], Float:vecStart] )
{

    new 
Float:vecHit];
    
vecStart] = vecTarget];
    
vecStart] = vecTarget];
    
vecStart] = vecTarget] + 5096.0;
    
    while( 
engfuncEngFunc_PointContentsvecStart ) != -)
    {
        if( 
vecStart] < vecTarget] + 128.0 )
            break;
            
        
vecStart] -= 16.0;
    }
    
    if( 
vecStart] - vecTarget] <= 196.0 )
        return 
0;
        
    
xs_vec_copyvecStartvecHit );
    
vecHit] += 256.0;
    
    new 
s_TextureName16 ];
    
engfuncEngFunc_TraceTexture0vecStartvecHits_TextureNamesizeofs_TextureName ) -);
    if( !
equals_TextureName"sky" ) )
        return 
0
    
    vecStart
] -= 10.0;
    return 
1;
}

/*====================================
=============Super Spawns============*/

public SsInit(Float:mindist)
{
    
    
register_cvar("sv_superspawns"SS_VERSION, (FCVAR_SERVER|FCVAR_SPONLY));
    
register_concmd("_ss_dump""SsDump");

    
g_flSsMinDist mindist;
    
g_vecSsOrigins ArrayCreate(31);
    
g_vecSsSpawns ArrayCreate(31);
    
g_vecSsUsed ArrayCreate(31);
}

stock SsClean()
{
    
g_flSsMinDist 0.0;
    
ArrayClear(g_vecSsOrigins);
    
ArrayClear(g_vecSsSpawns);
    
ArrayClear(g_vecSsUsed);
}

stock SsGetOrigin(Float:origin[3])
{
    new 
Float:data[3], size;
    new 
ok 1;

    while((
size ArraySize(g_vecSsOrigins)))
    {
        new 
idx random_num(0size 1);

        
ArrayGetArray(g_vecSsOriginsidxorigin);

        new 
used ArraySize(g_vecSsUsed);
        for(new 
0usedi++)
        {
            
ok 0;
            
ArrayGetArray(g_vecSsUsedidata);
            if(
get_distance_f(dataorigin) >= g_flSsMinDist)
            {
                
ok 1;
                break;
            }
        }

        
ArrayDeleteItem(g_vecSsOriginsidx);
        if(
ok)
        {
            
ArrayPushArray(g_vecSsUsedorigin);
            return 
true;
        }
    }
    return 
false;
}

public 
SsDump()
{
    new 
Float:origin[3], Float:fOrigin];
    new 
count ArraySize(g_vecSsOrigins);
    
server_print("-------------------------------------------------------");

    for(new 
0counti++)
    {
        
ArrayGetArray(g_vecSsOriginsiorigin);

        if( 
Get_Sky_OriginoriginfOrigin )  )
        {
            
ArrayPushArrayg_vecOriginsfOrigin );
            
g_iOrigins++;
        }
    }
    
}

public 
SsScan()
{
    new 
startFloat:origin[3], starttime;
    
starttime get_systime();
    for(
start 0start sizeof(g_szStarts); start++)
    {
        
server_print("Searching for %s"g_szStarts[start]);
        new 
ent;
        if((
ent engfunc(EngFunc_FindEntityByStringent"classname"g_szStarts[start])))
        {
            new 
counter;
            
pev(entpev_originorigin);
            
ArrayPushArray(g_vecSsSpawnsorigin);
            while(
counter SS_MAX_LOOPS)
            {
                
counter GetLocation(origincounter);
            }
        }
    }
    
g_iSsTime get_systime();
    
g_iSsTime -= starttime;
}

GetLocation(Float:start[3], &counter)
{
    new 
Float:end[3];
    for(new 
03i++)
    {
        
end[i] += random_float(0.0 g_flOffsets[i], g_flOffsets[i]);
    }

    if(
IsValid(startend))
    {
        
start[0] = end[0];
        
start[1] = end[1];
        
start[2] = end[2];
        
ArrayPushArray(g_vecSsOriginsend);
    }
    
counter++;
    return 
counter;
}

IsValid(Float:start[3], Float:end[3])
{
    
SetFloor(end);
    
end[2] += 36.0;
    new 
point engfunc(EngFunc_PointContentsend);
    if(
point == CONTENTS_EMPTY)
    {
        if(
CheckPoints(end) && CheckDistance(end) && CheckVisibility(startend))
        {
            if(!
trace_hull(endHULL_LARGE, -1))
            {
                return 
true;
            }
        }
    }
    return 
false;
}

CheckVisibility(Float:start[3], Float:end[3])
{
    new 
tr;
    
engfunc(EngFunc_TraceLinestartendIGNORE_GLASS, -1tr);
    return (
get_tr2(trTR_pHit) < 0);
}

SetFloor(Float:start[3])
{
    new 
trFloat:end[3];
    
end[0] = start[0];
    
end[1] = start[1];
    
end[2] = -99999.9;
    
engfunc(EngFunc_TraceLinestartendDONT_IGNORE_MONSTERS, -1tr);
    
get_tr2(trTR_vecEndPosstart);
}

CheckPoints(Float:origin[3])
{
    new 
Float:data[3], trpoint;
    
data[0] = origin[0];
    
data[1] = origin[1];
    
data[2] = 99999.9;
    
engfunc(EngFunc_TraceLineorigindataDONT_IGNORE_MONSTERS, -1tr);
    
get_tr2(trTR_vecEndPosdata);
    
point engfunc(EngFunc_PointContentsdata);
    if(
point == CONTENTS_SKY && get_distance_f(origindata) < 250.0)
    {
        return 
false;
    }
    
data[2] = -99999.9;
    
engfunc(EngFunc_TraceLineorigindataDONT_IGNORE_MONSTERS, -1tr);
    
get_tr2(trTR_vecEndPosdata);
    
point engfunc(EngFunc_PointContentsdata);
    if(
point CONTENTS_SOLID)
        return 
false;
    
    return 
true;
}

CheckDistance(Float:origin[3])
{
    new 
Float:distFloat:data[3];
    new 
count ArraySize(g_vecSsSpawns);
    for(new 
0counti++)
    {
        
ArrayGetArray(g_vecSsSpawnsidata);
        
dist get_distance_f(origindata);
        if(
dist SS_MIN_DISTANCE)
            return 
false;
    }

    
count ArraySize(g_vecSsOrigins);
    for(new 
0counti++)
    {
        
ArrayGetArray(g_vecSsOriginsidata);
        
dist get_distance_f(origindata);
        if(
dist SS_MIN_DISTANCE)
            return 
false;
    }

    return 
true;
}

/*====================================
=============Super Spawns============*/ 


Arkshine 12-09-2014 05:50

Re: Invalid cellvector handle provided
 
Invalid cellvector handle provided (6:2089803835:0)

6 = array handle, seems ok
2089803835 = array index you need, this seems wrong, is it expected to have that much item in an array?
0 = array size ; your array is empty which is probably unexpected.

bLacK-bLooD 12-09-2014 06:03

Re: Invalid cellvector handle provided
 
Okay, I'm a bit confused right now since it's more advanced compared to my curent knowledge in Pawn. Nevertheless, you said that the problem is the array's index which is wrong, which makes me think the problem is from the random( g_iOrigins ) function?

If yes, what's wrong with it? g_iOrigins gets incremented above in the SsDump() function.

Edit:
The array I have :
g_vecOrigins = ArrayCreate( 3, 1 ); //cellsize is set to 3 and reserved to 1, but this is not valid until we call ArraySet

Arkshine 12-09-2014 09:01

Re: Invalid cellvector handle provided
 
I did not read really your code, just explained the error.
But it's quite odd that it shows 0 as array size when you push array and increment g_iOrigins at the same time.
It's unlikely PushArray failed as pushing increases count and looking at the error, the count is 0, it's like the native was never called.
Really don't know without looking further. You should debug your code, see if native is well called and if data is well stored.


All times are GMT -4. The time now is 15:20.

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