Checkpoints appear in blueberry (0.0, 0.0, 0.0)
#1

Good Morning all
First off, i'd like to thank everyone on this forum, including but not limited to the SAMP developers and beta testers, for the amazing effort they put in.

Right, sentimental's over;
I seem to be having a rather annoying problem of arrays not giving me the right data... (well, not me obviously, you know what i mean)

I have an array (called Route101) which SHOULD contain 15 different coordinates, heres my array, and how i set it up:
pawn Код:
//Route 101 has 14 stops
enum RouteData {Float:x, Float:y, Float:z}
new Route101[13][RouteData];

stock BusMissionsInit()
{
    new i;
    Route101[i][x] = 169.3567; Route101[i][y] = -1739.3060; Route101[i][z] = 4.4763; i++;
    Route101[i][x] = 1196.5941; Route101[i][y] = -1855.5844; Route101[i][z] = 13.4955; i++;
    Route101[i][x] = 1826.2672; Route101[i][y] = -2100.1414; Route101[i][z] = 13.4835; i++;
    Route101[i][x] = 1964.9810; Route101[i][y] = -1768.8596; Route101[i][z] = 13.4783; i++;
    Route101[i][x] = 2357.9417; Route101[i][y] = -1752.7144; Route101[i][z] = 13.4793; i++;
    Route101[i][x] = 2639.3540; Route101[i][y] = -1771.4929; Route101[i][z] = 10.8091; i++;
    Route101[i][x] = 2710.5073; Route101[i][y] = -2021.2656; Route101[i][z] = 13.4003; i++;
    Route101[i][x] = 2861.2561; Route101[i][y] = -1911.4941; Route101[i][z] = 11.0386; i++;
    Route101[i][x] = 2514.9006; Route101[i][y] = 45.1526; Route101[i][z] = 26.4297; i++;
    Route101[i][x] = 1047.5758; Route101[i][y] = -949.7613; Route101[i][z] = 42.7522; i++;
    Route101[i][x] = 218.2735; Route101[i][y] = -1361.7000; Route101[i][z] = 50.7355; i++;
    Route101[i][x] = 752.9525; Route101[i][y] = -1583.7092; Route101[i][z] = 13.8202; i++;
    Route101[i][x] = 403.8641; Route101[i][y] = -1655.8706; Route101[i][z] = 29.5599; i++;
    Route101[i][x] = -132.1000; Route101[i][y] = -1650.4924; Route101[i][z] = 3.4956;
    print("Bus Route: 101 --------------");
    printf("Route101: %i stops created", i+1);
    print("-----------------------------");
    i = 0;
}
Now i know someone is going to say "Have you called BusMissionsInit" - so i'll answer it already: Yes, i have. In OnGameModeInit - with the rest of my objects/vehicles / resources.

I am using race checkpoints. Here is how i set them up:
pawn Код:
stop = pMission[playerid][busstop];
SetPlayerRaceCheckpoint(playerid, 0, Route101[stop][x], Route101[stop][y], Route101[stop][z], Route101[stop+1][x], Route101[stop+1][y], Route101[stop+1][z], C_SIZE);
I just cannot see where it is dying. Can anyone see what is wrong?

Thanks,
Ash
Reply
#2

should be
pawn Код:
new Route101[14][RouteData];
but other wize looks fine
Reply
#3

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
should be
pawn Код:
new Route101[14][RouteData];
but other wize looks fine
Numbering starts at 0 - and so 0 to 13 is 14 different integers
Reply
#4

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Numbering starts at 0 - and so 0 to 13 is 14 different integers
indeed, 0 to 13 are 14 values.
however, for dimension sizes you need to add one more to pawn.

If your array size is supposed to hold 15 integers, you need to define 16.
It's a fail I know, blame pawn.

PS: I see you added i++;
Compiler does not see i as a value, therefore it will not validate the dimension size and cause no error upon compiling.
If you would replace every i with a non-var number, it will error on the last dimension as your code is.
Reply
#5

Quote:
Originally Posted by funky1234
Посмотреть сообщение
Numbering starts at 0 - and so 0 to 13 is 14 different integers
Correct,but pawn doesn't count the number you put in the brackets.
For example,if you want to have 5 diffrent arguments,then:
PHP код:
New XXX[5][] 
It will do:
PHP код:
XXX[0][] = 
XXX[1][] = 
XXX[2][] = 
XXX[3][] = 
XXX[4][] = 
You see? it will make 5 arguments,not inclduing nubmer 5
it always does:
-1<X<Y
When X is the name of the argument (in your case: Route101) and Y is the number of arguments you want to have
Got it?
Reply
#6

Quote:
Originally Posted by maij
Посмотреть сообщение
indeed, 0 to 13 are 14 values.
however, for dimension sizes you need to add one more to pawn.

If your array size is supposed to hold 15 integers, you need to define 16.
It's a fail I know, blame pawn.

PS: I see you added i++;
Compiler does not see i as a value, therefore it will not validate the dimension size and cause no error upon compiling.
If you would replace every i with a non-var number, it will error on the last dimension as your code is.
i++ is the same as doing i + 1 ? (Incrementing the value)
i is an integer variable
+ I never said it was erroring', i stated "not working"



Quote:
Originally Posted by Montserrat
Посмотреть сообщение
Correct,but pawn doesn't count the number you put in the brackets.
For example,if you want to have 5 diffrent arguments,then:
PHP код:
New XXX[5][] 
It will do:
PHP код:
XXX[0][] = 
XXX[1][] = 
XXX[2][] = 
XXX[3][] = 
XXX[4][] = 
You see? it will make 5 arguments,not inclduing nubmer 5
it always does:
-1<X<Y
When X is the name of the argument (in your case: Route101) and Y is the number of arguments you want to have
Got it?
As i said...
I think i have sorted it now anyway, i think my "busstop" variable wasn't getting assigned correctly - i haven't actually tested it yet as i am no longer at my house, however it is what i am thinking (i have all my scripts on a remote network so i can access them from anywhere )
Reply
#7

Quote:
Originally Posted by funky1234
Посмотреть сообщение
i++ is the same as doing i + 1 ? (Incrementing the value)
i is an integer variable
+ I never said it was erroring', i stated "not working"





As i said...
I think i have sorted it now anyway, i think my "busstop" variable wasn't getting assigned correctly - i haven't actually tested it yet as i am no longer at my house, however it is what i am thinking (i have all my scripts on a remote network so i can access them from anywhere )
When you will be back home tell us if it was fixed
Reply
#8

Quote:
Originally Posted by funky1234
Посмотреть сообщение
i++ is the same as doing i + 1 ? (Incrementing the value)
i is an integer variable
+ I never said it was erroring', i stated "not working"





As i said...
I think i have sorted it now anyway, i think my "busstop" variable wasn't getting assigned correctly - i haven't actually tested it yet as i am no longer at my house, however it is what i am thinking (i have all my scripts on a remote network so i can access them from anywhere )
If there aren't errors then your stuff would be working.
A state of not working is always caused by errors. The cause of warnings or misinterpretation by the server/browsers are usually caused by either misunderstood errors or typing errors.

pawn Код:
i++;
//as you said, i++ does assign original value +1 to i. does work as it is a standard part of usually any scripting/programming language.
remote network is a good idea! I second that idea.
Consider security though, you don't want your stuff to be stolen.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)