for(new < bugs!!!!!
#1

i define this

#define MAX_FAMILY 1000

and this is my code


PHP код:
CMD:allfam(playeridparams[])
{
     new 
string[512];
     
SCM(playerid,COLOR_LIGHTBLUE"-------------------¤ГНє¤ГСЗ·ХиКГйТ§бЕйЗ--------------------");
    for(new 
i=1i<= MAX_FAMILYi++)
    {
        if(
FamilyInfo[i][fCreate] == 1)
        {
            
format(stringsizeof(string), "КЕкНµ·Хи %i | ¤ГНє¤ГСЗ: %s | ЛСЗЛ№йТ: %s | КБТЄФЎ %i ¤№ "iFamilyInfo[i][fName], FamilyInfo[i][fOwner], count);
            
SCM(playerid,0x09F797C8string);
            
count 0;
        }
    }
    return 
1;

Command work fine but it also said unknown command

but when i change this

PHP код:
    for(new i=1i<= MAX_FAMILYi++)
    { 
to

PHP код:
    for(new i=1i<= 950i++)
    { 
it work fine and don't send the unknown fuckin message

but when i try to redefine

PHP код:
#define MAX_FAMILY 950 
and change this

PHP код:
    for(new i=1i<= 950i++)
    { 
back to

PHP код:
    for(new i=1i<= MAX_FAMILYi++)
    { 
it still fuckin send unknown fuckin messageeeeeee

it happen to all stuff how to fixed it
Reply
#2

Where did you place the #define? What's the exact error message?

Also, what language is that?
Reply
#3

Quote:
Originally Posted by AnthonyTimmers
Посмотреть сообщение
Where did you place the #define? What's the exact error message?

Also, what language is that?
I PLACE THE DEFINE ON TOP OF SCRIPT

and i know it right

but i thinkk you don't understood the point of me

it not send error it send unknown command but the command is workk

i mean when i use i< 1000 i ++ it send the unknown command

but i try to use i< 50 i++ it work fine without unknown meassge

btw language is thai
Reply
#4

Код:
for(new i=0; i < MAX_FAMILY; i++)
Maybe loop goes out of array bounds?
Reply
#5

still not fix
Reply
#6

How about that?
Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
Reply
#7

Quote:
Originally Posted by DrumYum
Посмотреть сообщение
How about that?
Код:
for(new i = 0; i < sizeof(FamilyInfo); i++)
still not
Reply
#8

Then just keep it as 1000, MAX_FAMILY is just a number '1000'.

MAX_FAMILY = Number
MAX_PLAYERS = Number
MAX_VEHICLES = Number

...
I hope you get the point - Every #define MAX_* Is basically the "last number" for something, it's not something special.
Reply
#9

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Then just keep it as 1000, MAX_FAMILY is just a number '1000'.

MAX_FAMILY = Number
MAX_PLAYERS = Number
MAX_VEHICLES = Number

...
I hope you get the point - Every #define MAX_* Is basically the "last number" for something, it's not something special.
i forgot to tell you it work fine on i < 950 but when i< 1000 it also send unknown message
Reply
#10

pawn Код:
for(new i=1; i < MAX_FAMILY; i++)
Since you created the array FamilyInfo using something similar as this:
pawn Код:
new FamilyInfo[MAX_FAMILY][EnumFamily];
You're in fact creating an array with 1000 indices, going from index 0 to 999.
Your loop ran from 1 to 1000 because of the "i <= MAX_FAMILY".
You have to run it from 1 to MAX_FAMILY-1, or just use the above code (i < MAX_FAMILY).

That's why your command gave you "Unknown command" because it crashed while accessing the array at index 1000, while the max index is only 999 (index-out-of-bounds error).
And that's also when you set the loop to run from 1 to 950, everything works fine, because you won't go outside the array's lower or upper indices.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)