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

Solved Invalid cellvector handle


Post New Thread Reply   
 
Thread Tools Display Modes
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-23-2018 , 10:13   Re: Invalid cellvector handle
Reply With Quote #21

Quote:
Originally Posted by edon1337 View Post
Well, I'm not clearing it either?
PHP Code:
public RoundStarted( ) 

    
ArrayClearg_aOrigins ); // This is a clear btw :D
    
RetrieveOrigins( ); 
     
    
GetRandomOriginfOrigin );  

__________________
stuff

Last edited by maqi; 07-23-2018 at 10:14.
maqi is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-23-2018 , 10:17   Re: Invalid cellvector handle
Reply With Quote #22

Quote:
You should create a minimal (self-contained) compilable and runnable example that produces the issue so everyone can test it out.
Do that, disable all other plugins and test it out. NO SIDE EFFECTS. If it produces the error then post the code. Nobody wants to assume what // code is or what RoundStarted actually is in your example. If you want people to help you then you should make it easy for them.
__________________
klippy is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-23-2018 , 10:32   Re: Invalid cellvector handle
Reply With Quote #23

Code:
 new iRandomEntry = random_num( 0, ArraySize( g_aOrigins ) );
Code:
 new iRandomEntry = random_num( 0, ArraySize( g_aOrigins ) - 1);
Plus Check if Array has any item.

if (!ArraySize(g_aOrigins))
return;
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 07-23-2018 at 10:35.
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-23-2018 , 11:37   Re: Invalid cellvector handle
Reply With Quote #24

Quote:
Originally Posted by maqi View Post
PHP Code:
public RoundStarted( ) 

    
ArrayClearg_aOrigins ); // This is a clear btw :D
    
RetrieveOrigins( ); 
     
    
GetRandomOriginfOrigin );  

Nice finding Sherlock, but that clear is executed before the functions.

Quote:
Originally Posted by Ghosted View Post
Code:
 new iRandomEntry = random_num( 0, ArraySize( g_aOrigins ) );
Code:
 new iRandomEntry = random_num( 0, ArraySize( g_aOrigins ) - 1);
Plus Check if Array has any item.

if (!ArraySize(g_aOrigins))
return;
According to your logic, if ArraySize is 0, 0 - 1 = -1, which is incorrect.

If I check ArraySize, it will stop the error, but won't fix my problem.
__________________
edon1337 is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-23-2018 , 11:52   Re: Invalid cellvector handle
Reply With Quote #25

Quote:
Originally Posted by edon1337 View Post
Nice finding Sherlock, but that clear is executed before the functions.
Don't give me that attitude again dude, check your code again, accept when you are wrong.

As for what Ghosted said:
First check if array has items, then and only then u can generate a random integer to index it. So your argument there is invalid also.
__________________
stuff

Last edited by maqi; 07-23-2018 at 11:57.
maqi is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-23-2018 , 12:02   Re: Invalid cellvector handle
Reply With Quote #26

Quote:
Originally Posted by maqi View Post
Don't give me that attitude again dude, check your code again, accept when you are wrong.

As for what Ghosted said:
First check if array has items, then and only then u can generate a random integer to index it. So your argument there is invalid also.
What attitude are you talking about dude? You're so persistent on your false self-created imaginary opinion of me being mean to you.

Again, if I check if array is empty and just stop the action, I won't get anything generated. So stop replying non-sense around. And here's the proof that shows my point is valid, because otherwise you keep on bothering.
PHP Code:
L 07/23/2018 18:00:26#1 Size: 0
L 07/23/2018 18:00:26#2 Size: 0
L 07/23/2018 18:00:26#2 Size: 1
L 07/23/2018 18:00:26#2 Size: 2
L 07/23/2018 18:00:26#2 Size: 3
L 07/23/2018 18:00:26#2 Size: 4
L 07/23/2018 18:00:26#2 Size: 5
L 07/23/2018 18:00:26#2 Size: 6
L 07/23/2018 18:00:26#2 Size: 7
L 07/23/2018 18:00:26#2 Size: 8
L 07/23/2018 18:00:26#2 Size: 9
L 07/23/2018 18:00:26#2 Size: 10
L 07/23/2018 18:00:26#2 Size: 11
L 07/23/2018 18:00:26#2 Size: 12
L 07/23/2018 18:00:26#2 Size: 13
L 07/23/2018 18:00:26#2 Size: 14
L 07/23/2018 18:00:26#2 Size: 15
L 07/23/2018 18:00:26#2 Size: 16
L 07/23/2018 18:00:26#2 Size: 17
L 07/23/2018 18:00:26#2 Size: 18
L 07/23/2018 18:00:26#2 Size: 19
L 07/23/2018 18:00:26#2 Size: 20
L 07/23/2018 18:00:26#2 Size: 21
L 07/23/2018 18:00:26#2 Size: 22
L 07/23/2018 18:00:26#2 Size: 23
L 07/23/2018 18:00:26#2 Size: 24
L 07/23/2018 18:00:26#2 Size: 25
L 07/23/2018 18:00:26#2 Size: 26
L 07/23/2018 18:00:26#2 Size: 27
L 07/23/2018 18:00:26#2 Size: 28
L 07/23/2018 18:00:26#2 Size: 29
L 07/23/2018 18:00:26#2 Size: 30
L 07/23/2018 18:00:26#2 Size: 31
L 07/23/2018 18:00:26#2 Size: 32
L 07/23/2018 18:00:26#2 Size: 33
L 07/23/2018 18:00:26#2 Size: 34
L 07/23/2018 18:00:26#2 Size: 35
L 07/23/2018 18:00:26#2 Size: 36
L 07/23/2018 18:00:26#2 Size: 37
L 07/23/2018 18:00:26#2 Size: 38
L 07/23/2018 18:00:26#2 Size: 39
L 07/23/2018 18:00:26#2 Size: 40
L 07/23/2018 18:00:32#1 Size: 0
L 07/23/2018 18:00:32#4 0.0 0.0 0.0 
Quote:
Originally Posted by KliPPy View Post
Do that, disable all other plugins and test it out. NO SIDE EFFECTS. If it produces the error then post the code. Nobody wants to assume what // code is or what RoundStarted actually is in your example. If you want people to help you then you should make it easy for them.
Samr thing, disabled all plugins.

PHP Code:
#include < amxmodx >
#include < superspawns >

#define MAX_ORIGINS 100

enum _:OriginDimensions
{
Float:ORIGIN]
}

new Array:
g_aOrigins;

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

    
RetrieveOrigins( );
    
    
register_logevent"OnNewRound"2"1=Round_Start" );
}

public 
plugin_precache( )
{
    
g_aOrigins ArrayCreateOriginDimensions );
}

public 
OnNewRound( )
{
    new 
Float:fOrigin];

    
ArrayClearg_aOrigins );
    
RetrieveOrigins( );

    
GetRandomOriginfOrigin );

    
log_to_file"Array.txt""#4 %.1f %.1f %.1f"fOrigin], fOrigin], fOrigin] );
}

RetrieveOrigins( )
{
    
log_to_file"Array.txt""#1 Size: %d"ArraySizeg_aOrigins ) );

    new 
Float:fOrigin];

    for( new 
i=1<= MAX_ORIGINSi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            
SaveOriginfOrigin );
        }
    }
}

SaveOriginFloat:fOrigin] )
{
    
log_to_file"Array.txt""#2 Size: %d"ArraySizeg_aOrigins ) );

    new 
eDataOriginDimensions ];

    
eDataORIGIN ][ ] = _:fOrigin];
    
eDataORIGIN ][ ] = _:fOrigin];
    
eDataORIGIN ][ ] = _:fOrigin];

    
ArrayPushArrayg_aOriginseData );
}

GetRandomOriginFloat:fOrigin] )
{
    new 
eDataOriginDimensions ];

    if( ! 
ArraySizeg_aOrigins ) )
    return 
PLUGIN_HANDLED;
    
    new 
iRandomEntry random_num0ArraySizeg_aOrigins ) );

    
log_to_file"Array.txt""#3 Size: %d | Entry: %d"ArraySizeg_aOrigins ), iRandomEntry );

    
ArrayGetArrayg_aOriginsiRandomEntryeData );

    
fOrigin] = eDataORIGIN ][ ];
    
fOrigin] = eDataORIGIN ][ ];
    
fOrigin] = eDataORIGIN ][ ];

    
ArrayDeleteItemg_aOriginsiRandomEntry );
    return 
PLUGIN_CONTINUE;

__________________

Last edited by edon1337; 07-23-2018 at 12:05.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 07-23-2018 , 12:24   Re: Invalid cellvector handle
Reply With Quote #27

Literally impossible to figure out. I've lost count how many times I told you to debug everything in your code, EVERY SINGLE LINE. Most of your threads could have been resolved if you properly debugged. And no, putting 4 log_to_file is not proper debugging. Take each piece of code and see how it executes, instruction by instruction.

Now, on a more serious note, it's quite obvious. On first call(from plugin_init) you populate the g_aOrigins array.
Then on new round your clear that array and try to fill it again. What happens is that it's simply not filled again.
Why? With a debug code like:
PHP Code:
    for( new i=1<= MAX_ORIGINSi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            
server_print("Adding origin")
            
SaveOriginfOrigin );
        }
        else 
        {
            
server_print("Out of points")
        }
    } 
You would see SsGetOrigin will always return false("Out of points" is being printed) on calls from NewRound. It happens because you never call SsScan in NewRound and once the first set of calls to SsGetOrigin(from plugin_init) is finished the underlying array used by superspawn becomes empty.
__________________

Last edited by HamletEagle; 07-23-2018 at 12:26.
HamletEagle is offline
maqi
Senior Member
Join Date: Apr 2017
Location: Serbia
Old 07-23-2018 , 12:24   Re: Invalid cellvector handle
Reply With Quote #28

Quote:
Originally Posted by edon1337 View Post
What attitude are you talking about dude? You're so persistent on your false self-created imaginary opinion of me being mean to you.
We are not here to talk about our feelings, second time already I offered to help, and you insist on things like "Read the code before posting" and "No shit sherlock". And if I might add I did read the code both of the times and was right both of the times.

Anyway, what is your question now ?
- We told you how to prevent the error
- We told you why the array gets cleared
__________________
stuff
maqi is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-23-2018 , 12:39   Re: Invalid cellvector handle
Reply With Quote #29

Quote:
Originally Posted by HamletEagle View Post
Literally impossible to figure out. I've lost count how many times I told you to debug everything in your code, EVERY SINGLE LINE. Most of your threads could have been resolved if you properly debugged. And no, putting 4 log_to_file is not proper debugging. Take each piece of code and see how it executes, instruction by instruction.
Agree, most of Scripting Help posts are caused by not using this debugging option.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-23-2018 , 14:50   Re: Invalid cellvector handle
Reply With Quote #30

Quote:
Originally Posted by HamletEagle View Post
Literally impossible to figure out. I've lost count how many times I told you to debug everything in your code, EVERY SINGLE LINE. Most of your threads could have been resolved if you properly debugged. And no, putting 4 log_to_file is not proper debugging. Take each piece of code and see how it executes, instruction by instruction.

Now, on a more serious note, it's quite obvious. On first call(from plugin_init) you populate the g_aOrigins array.
Then on new round your clear that array and try to fill it again. What happens is that it's simply not filled again.
Why? With a debug code like:
PHP Code:
    for( new i=1<= MAX_ORIGINSi++ )
    {
        if( 
SsGetOriginfOrigin ) )
        {
            
server_print("Adding origin")
            
SaveOriginfOrigin );
        }
        else 
        {
            
server_print("Out of points")
        }
    } 
You would see SsGetOrigin will always return false("Out of points" is being printed) on calls from NewRound. It happens because you never call SsScan in NewRound and once the first set of calls to SsGetOrigin(from plugin_init) is finished the underlying array used by superspawn becomes empty.
I was so focused on ArrayGetArray that I forgot superspawns would have ran out of points. Thanks.
By any chance I can move SsScan from RoundStart to precache/init so it doesn't freeze the players while it loops 100,000 times?

Quote:
Originally Posted by maqi View Post
We are not here to talk about our feelings
Correct, but you're the one who's getting hurt while I'm not even saying anything to you.

Quote:
Originally Posted by maqi View Post
And if I might add I did read the code both of the times and was right both of the times.
I don't think you read the codes properly, and no, you were wrong, I already gave you the proof, why are you claiming you were right?

Quote:
Originally Posted by maqi View Post
- We told you how to prevent the error
Preventing an error from appearing isn't the same as fixing it.

Quote:
Originally Posted by maqi View Post
- We told you why the array gets cleared
You did? Maybe because I was clearing it?
__________________

Last edited by edon1337; 07-23-2018 at 14:51.
edon1337 is offline
Reply


Thread Tools
Display Modes

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 09:36.


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