Raised This Month: $51 Target: $400
 12% 

Solved Invalid cellvector handle


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-22-2018 , 18:08   Invalid cellvector handle
Reply With Quote #1

Am I missing something here?

PHP Code:
enum _:OriginDimensions
{
    
Float:ORIGIN]
}

new Array:
g_aOrigins;

public 
plugin_init( )
{
    
SsInit1000.0 );
    
SsScan( );
    
SsDump( );
    
    
RetrieveOrigins( );
}

public 
plugin_precache( )
{
    
g_aOrigins ArrayCreateOriginDimensions );
}

public 
RoundStarted( )
{
    
ArrayClearg_aOrigins );
    
RetrieveOrigins( );
    
    
GetRandomOriginfOrigin );
    
    
// code
}

RetrieveOrigins( )
{
    new 
Float:fOrigin];
    
    for( new 
i=1<= MAX_ORIGINSi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            
SaveOriginfOrigin );
        }
    }
}

SaveOriginFloat:fOrigin] )
{
    new 
eDataOriginDimensions ];

    
eDataORIGIN ][ ] = _:fOrigin];
    
eDataORIGIN ][ ] = _:fOrigin];
    
eDataORIGIN ][ ] = _:fOrigin];
    
    
ArrayPushArrayg_aOriginseData );
}

GetRandomOriginFloat:fOrigin] )
{
    new 
eDataOriginDimensions ];

    new 
iRandomEntry random_num0ArraySizeg_aOrigins ) );
    
    
ArrayGetArrayg_aOriginsiRandomEntryeData );

    
fOrigin] = eDataORIGIN ][ ];
    
fOrigin] = eDataORIGIN ][ ];
    
fOrigin] = eDataORIGIN ][ ];
    
    
ArrayDeleteItemg_aOriginsiRandomEntry );

Quote:
L 07/22/2018 - 23:21:53: Invalid cellvector handle provided (1:0:0)
L 07/22/2018 - 23:21:53: [AMXX] Displaying debug trace (plugin "CsBattleRoyale.amxx")
L 07/22/2018 - 23:21:53: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 07/22/2018 - 23:21:53: [AMXX] [0] CsBattleRoyale.sma::GetRandomOrigin (line 1011)
L 07/22/2018 - 23:21:53: [AMXX] [1] CsBattleRoyale.sma::RoundStarted (line 375)
__________________

Last edited by edon1337; 07-30-2018 at 17:59.
edon1337 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-22-2018 , 18:36   Re: Invalid cellvector handle
Reply With Quote #2

The line numbers.
ArrayCreate() was not called before using ArrayGetArray().
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-22-2018 , 18:50   Re: Invalid cellvector handle
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
The line numbers.
ArrayCreate() was not called before using ArrayGetArray().
It's already obvious, how many times is ArrayGetArray being used? Once.

Quote:
Originally Posted by OciXCrom View Post
ArrayCreate() was not called before using ArrayGetArray().
Don't really get it, I'm using ArrayClear not ArrayDestroy, so why would I have to call ArrayCreate every time?
__________________
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-22-2018 , 20:06   Re: Invalid cellvector handle
Reply With Quote #4

You are trying to get from an empty array.
__________________
stuff
maqi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-22-2018 , 21:07   Re: Invalid cellvector handle
Reply With Quote #5

If the array was empty, the error would have been "invalid index", not "invalid handle". The only way this error can show if is either ArrayCreate() wasn't called or ArrayDestroy() was used. Check your entire plugin_precache() function, something may be preventing the code from reaching ArrayCreate() - check your error logs for other errors in the plugin, especially when starting the server.
__________________

Last edited by OciXCrom; 07-22-2018 at 21:08.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-22-2018 , 21:25   Re: Invalid cellvector handle
Reply With Quote #6

I think you are wrong. It's always the same error, where the first parameter indicates the handle id, the second index to get and the third size of the array, as the size is 0, there is nothing to get, therefor the error.

Code:
// ArrayGetArray(Array:which, item, any:output[]);
static cell AMX_NATIVE_CALL ArrayGetArray(AMX* amx, cell* params)
{
	CellVector* vec=HandleToVector(amx, params[1]);

	if (vec==NULL)
	{
		return 0;
	}

	if (vec->GetArray(params[2],get_amxaddr(amx, params[3]))!=1)
	{
		LogError(amx, AMX_ERR_NATIVE, "Invalid cellvector handle provided (%d:%d:%d)", params[1], params[2], vec->Size());
		return 0;
	}

	return 1;
}
__________________
stuff
maqi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-23-2018 , 07:41   Re: Invalid cellvector handle
Reply With Quote #7

Check if the array is not empty.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-23-2018 , 07:46   Re: Invalid cellvector handle
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
Check if the array is not empty.
Is there a native for it or do I check manually each item?
__________________
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-23-2018 , 07:47   Re: Invalid cellvector handle
Reply With Quote #9

ArraySize()
__________________
stuff
maqi is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-23-2018 , 07:57   Re: Invalid cellvector handle
Reply With Quote #10

Quote:
Originally Posted by maqi View Post
I think you are wrong. It's always the same error, where the first parameter indicates the handle id, the second index to get and the third size of the array, as the size is 0, there is nothing to get, therefor the error.

Code:
// ArrayGetArray(Array:which, item, any:output[]);
static cell AMX_NATIVE_CALL ArrayGetArray(AMX* amx, cell* params)
{
	CellVector* vec=HandleToVector(amx, params[1]);

	if (vec==NULL)
	{
		return 0;
	}

	if (vec->GetArray(params[2],get_amxaddr(amx, params[3]))!=1)
	{
		LogError(amx, AMX_ERR_NATIVE, "Invalid cellvector handle provided (%d:%d:%d)", params[1], params[2], vec->Size());
		return 0;
	}

	return 1;
}
Um, where did you even find that? The code in github is completelly different:

PHP Code:
// native ArrayGetArray(Array:which, item, any:output[], size = -1);
static cell AMX_NATIVE_CALL ArrayGetArray(AMXamxcellparams)
{
    
CellArrayvec ArrayHandles.lookup(params[1]);

    if (!
vec)
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid array handle provided (%d)"params[1]);
        return 
0;
    }

    
size_t idx = (size_t)params[2];

    if (
idx >= vec->size())
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid index %d (count: %d)"idxvec->size());
        return 
0;
    }

    
cell *blk vec->at(idx);
    
size_t indexes vec->blocksize();

    if (*
params sizeof(cell) == 4)
    {
        if (
params[4] != -&& (size_t)params[4] <= vec->blocksize())
        {
            
indexes params[4];
        }
    }

    
cell *addr get_amxaddr(amxparams[3]);

    
memcpy(addrblksizeof(cell) * indexes);

    return 
indexes;

I assume it's much different in 1.8.2.
__________________

Last edited by OciXCrom; 07-23-2018 at 07:58.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 07:40.


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