Raised This Month: $ Target: $400
 0% 

Array Sizes do not match


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-05-2007 , 18:27   Array Sizes do not match
Reply With Quote #1

Lines 639-640:
Code:
		get_user_origin ( i, origin[3] );
		FS_Should_Burn_Victim ( origin[3], burnvec1, burnvec2, radius, i, id, tempff );
Lines 399-403:
Code:
public FS_Should_Burn_Victim ( origin[], burnvec1[], burnvec2[], radius, i, id, ff )
{
	if ( ( is_user_alive ( i ) == 1 ) && ( i != id ) )
	{
		if ( ( get_distance ( origin, burnvec1 ) < radius ) || ( get_distance ( origin[3], burnvec2 ) < radius ) )
Why are lines 399-403 giving me
Code:
error 47: array sizes do not match...
Lines 639-640 are correct AFAIK, but 399-403 are reciprocating this error. I tried a variety of things but none worked.

Initialization of origin:
Code:
new origin[33][3];
I have been following the following threads/docs:
http://forums.alliedmods.net/showthr...%22array+sizes
www.doomworld.com/eternity/engine/smalldoc.pdf

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-05-2007 , 18:53   Re: Array Sizes do not match
Reply With Quote #2

Hi,
i think i know what is wrong in your script..

Code:
first: get_user_origin ( i, origin[i]);
second: FS_Should_Burn_Victim (origin[id], burnvec1, burnvec2, radius, i, id, tempff );
third: if ( ( get_distance ( origin, burnvec1 ) < radius ) || ( get_distance ( origin[i or id], burnvec2 ) < radius ) )

If you declare a array origin[3] you can do just get_user_origin(id, origin)

To send the array as a parameter in a function call just do function(origin)

And if you got an array origin[33][3] just declare the first dimension like get_user_origin(id, origin[id]) and function(origin[id])

Hope that helps

greetz regalis
__________________
regalis is offline
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 06-05-2007 , 18:58   Re: Array Sizes do not match
Reply With Quote #3

The problem is pretty self explanatory.

As regalis said you are not setting origin correctly! For retrieving and setting data it should have origin[id] since it is a 2 dimensional array.

Ideally you should use a declared size for arrays in your function.
1) For error checking if you try going beyond the size
2) So Pawn knows exactly how much memory to allocate.

Code:
public function1(id) {     new pOrigin[3]     get_user_origin(id, pOrigin)     function2(pOrigin) } function2(origin[3]) {     client_print(0, print_chat, "X: %i - Y: %i - Z: %i", origin[0], origin[1], origin[2]) }
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd

Last edited by Orangutanz; 06-05-2007 at 19:04.
Orangutanz is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-05-2007 , 19:11   Re: Array Sizes do not match
Reply With Quote #4

Thank you both for your help, but I still have not been able to remove that error.

Here's more code because I substituted what you guys said in, both ways, and neither worked:

PHP Code:
public FS_Should_Burn_Victim origin[], burnvec1[], burnvec2[], radiusiidff )
{
    if ( ( 
is_user_alive ) == ) && ( != id ) )
    {
        if ( ( 
get_distance origin[i], burnvec1 ) < radius ) || ( get_distance origin[i], burnvec2 ) < radius ) )
        {
            
TASK_Burn_Victim iidff );
        }
    }

and

PHP Code:
public TASK_Check_BurnZone idvec[], aimvec[], speed1speed2radius )
{
    new 
maxplayers get_maxplayers ( ) + 1;
    new 
tbodytid;
    
get_user_aiming idtidtbody550 );

    new 
ff 0;

    if ( 
cvar_exists "mp_friendlyfire" ) )
    {
        new 
ffcvar get_cvar_num "mp_friendlyfire" );

        if ( ( 
ffcvar == ) || ( ffcvar == ) )
        {
            
ff ffcvar;
        }
    }

    if ( ( 
tid ) && ( tid maxplayers ) )
    {
        
TASK_Burn_Victim tididff ) ;
    }

    new 
burnvec1[4],burnvec2[4],length1;

    
burnvec1[0]=aimvec[0]-vec[0];
    
burnvec1[1]=aimvec[1]-vec[1];
    
burnvec1[2]=aimvec[2]-vec[2];

    
length1=sqrt burnvec1[0]*burnvec1[0]+burnvec1[1]*burnvec1[1]+burnvec1[2]*burnvec1[2] );
    
burnvec2[0] = burnvec1[0] * speed2/length1;
    
burnvec2[1] = burnvec1[1] * speed2/length1;
    
burnvec2[2] = burnvec1[2] * speed2/length1;
    
burnvec1[0] = burnvec1[0] * speed1/length1;
    
burnvec1[1] = burnvec1[1] * speed1/length1;
    
burnvec1[2] = burnvec1[2] * speed1/length1;
    
burnvec1[0] += vec[0];
    
burnvec1[1] += vec[1];
    
burnvec1[2] += vec[2];
    
burnvec2[0] += vec[0];
    
burnvec2[1] += vec[1];
    
burnvec2[2] += vec[2];
    
    new 
origin[33][3];

    for ( new 
i=1<= maxplayersi++ ) 
    {        
        new 
tempff ff;

        if ( 
ff == )
        {
            if ( 
get_user_team(i) == get_user_team(id) )
            {
                
tempff 1;
            }
        }

        
get_user_origin iorigin[i] );
        
FS_Should_Burn_Victim origin[id], burnvec1burnvec2radiusiidtempff );
    }

    return 
PLUGIN_CONTINUE;

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 06-05-2007 , 19:21   Re: Array Sizes do not match
Reply With Quote #5

Are you sure that there have to be two times "i" in there?
Code:
if ( ( get_distance ( origin[i], burnvec1 ) < radius ) || ( get_distance ( origin[i], burnvec2 ) < radius ) ) 
I don't know what this code do...and im sorry that i have to go sleep...0o
Too tired right now.
Everything else looks good so far i can see...

greetz regalis
__________________
regalis is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-05-2007 , 19:35   Re: Array Sizes do not match
Reply With Quote #6

I don't know what I need and what I don't because this is confusing me really badly. I have tried re-reading all docs/information on this subject but I think I just need someone else to help me with the issue directly.

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
pRED*
Join Date: Dec 2006
Old 06-05-2007 , 19:57   Re: Array Sizes do not match
Reply With Quote #7

I'm pretty sure it will be the function headers..

Instead of being origin[], make it origin[3] etc etc.

[] is for strings, since vectors have a fixed sized you should specify this.
pRED* is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-05-2007 , 20:07   Re: Array Sizes do not match
Reply With Quote #8

1) Verry sloppy for loop
2) Why did you do this
PHP Code:
new origin[33][3]; 
if you only use it to pass a single origin as a function call ?
3) The root of the problem is in here
PHP Code:
public FS_Should_Burn_Victim origin[], burnvec1[], burnvec2[], radiusiidff 

    if ( ( 
is_user_alive ) == ) && ( != id ) ) 
    { 
        if ( ( 
get_distance origin[i], burnvec1 ) < radius ) || ( get_distance origin[i], burnvec2 ) < radius ) ) 
        { 
            
TASK_Burn_Victim iidff ); 
        } 
    } 

Inside that function the "origin" variable is that from the argument line, NOT that one declared in your other function (where it was declared as private btw). You cannot do origin[i] here. Taking this a step forward: get_distance() expects 2 vectors like vec1[3] and vec2[3]; origin[i] is interpreted as origin[i][0], origin[i][1] and origin[i][2] (2D arrays). At this poin it conflicts with the local function argument origin[] (1D array). Review point 1 and 2 and your problem will get solved by itself.

Last edited by _Master_; 06-05-2007 at 20:13.
_Master_ is offline
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 06-05-2007 , 20:23   Re: Array Sizes do not match
Reply With Quote #9

Quote:
Originally Posted by _Master_ View Post
1) Verry sloppy for loop
2) Why did you do this
PHP Code:
new origin[33][3]; 
if you only use it to pass a single origin as a function call ?
3) The root of the problem is in here
PHP Code:
public FS_Should_Burn_Victim origin[], burnvec1[], burnvec2[], radiusiidff 

    if ( ( 
is_user_alive ) == ) && ( != id ) ) 
    { 
        if ( ( 
get_distance origin[i], burnvec1 ) < radius ) || ( get_distance origin[i], burnvec2 ) < radius ) ) 
        { 
            
TASK_Burn_Victim iidff ); 
        } 
    } 

Inside that function the "origin" variable is that from the argument line, NOT that one declared in your other function (where it was declared as private btw). You cannot do origin[i] here. Taking this a step forward: get_distance() expects 2 vectors like vec1[3] and vec2[3]; origin[i] is interpreted as origin[i][0], origin[i][1] and origin[i][2] (2D arrays). At this poin it conflicts with the local function argument origin[] (1D array). Review point 1 and 2 and your problem will get solved by itself.
Thank you for the explanation but since this is code I am reviewing for someone else, I don't understand, therefore, I am getting the same error and I am too frustrated to think!!!

Current Code:
PHP Code:
public FS_Should_Burn_Victim origin[3], burnvec1[], burnvec2[], radiusiidff )
{
    if ( ( 
is_user_alive ) == ) && ( != id ) )
    {
        if ((
get_distance(origin[id],burnvec1) < radius) || (get_distance (origin[id],burnvec2) < radius ) )
        {
            
TASK_Burn_Victim iidff );
        }
    }

PHP Code:
public TASK_Check_BurnZone idvec[], aimvec[], speed1speed2radius )
{
    new 
maxplayers get_maxplayers ( ) + 1;
    new 
tbodytid;
    
get_user_aiming idtidtbody550 );

    new 
ff 0;

    if ( 
cvar_exists "mp_friendlyfire" ) )
    {
        new 
ffcvar get_cvar_num "mp_friendlyfire" );

        if ( ( 
ffcvar == ) || ( ffcvar == ) )
        {
            
ff ffcvar;
        }
    }

    if ( ( 
tid ) && ( tid maxplayers ) )
    {
        
TASK_Burn_Victim tididff ) ;
    }

    new 
burnvec1[4],burnvec2[4],length1;

    
burnvec1[0]=aimvec[0]-vec[0];
    
burnvec1[1]=aimvec[1]-vec[1];
    
burnvec1[2]=aimvec[2]-vec[2];

    
length1=sqrt burnvec1[0]*burnvec1[0]+burnvec1[1]*burnvec1[1]+burnvec1[2]*burnvec1[2] );
    
burnvec2[0] = burnvec1[0] * speed2/length1;
    
burnvec2[1] = burnvec1[1] * speed2/length1;
    
burnvec2[2] = burnvec1[2] * speed2/length1;
    
burnvec1[0] = burnvec1[0] * speed1/length1;
    
burnvec1[1] = burnvec1[1] * speed1/length1;
    
burnvec1[2] = burnvec1[2] * speed1/length1;
    
burnvec1[0] += vec[0];
    
burnvec1[1] += vec[1];
    
burnvec1[2] += vec[2];
    
burnvec2[0] += vec[0];
    
burnvec2[1] += vec[1];
    
burnvec2[2] += vec[2];
    
    new 
origin[3];

    for ( new 
i=1<= maxplayersi++ ) 
    {        
        new 
tempff ff;

        if ( 
ff == )
        {
            if ( 
get_user_team(i) == get_user_team(id) )
            {
                
tempff 1;
            }
        }

        
get_user_origin iorigin );
        
FS_Should_Burn_Victim originburnvec1burnvec2radiusiidtempff );
    }

    return 
PLUGIN_CONTINUE;

Whoever can fix it gets praise b/c it has pissed me off for more than an hour too long!!!!!!!!!!!!!!!!!

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-05-2007 , 20:27   Re: Array Sizes do not match
Reply With Quote #10

One more thing:
PHP Code:
new burnvec1[4],burnvec2[4
should be
PHP Code:
new burnvec1[3],burnvec2[3
I do believe this issues the error

Last edited by _Master_; 06-05-2007 at 21:50.
_Master_ 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 10:41.


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