Array Index problem
#1

alright so the old common problem, just not sure where Im making a mistake

PHP код:
new PlayerText:TXT_TD_Text[MAX_PLAYERS][12];
new 
PlayerWeapon[MAX_PLAYERS][13][P_WEAPONS];
for (new 
0<= 12i++) {
        
PlayerTextDrawSetPreviewRot(playerid,TXT_TD_Update[playerid][i], 0,0,05.0);
        switch(
PlayerWeapon[playerid][i][P_WeaponID]) {
            case 
0: { format(string,sizeof(string),"Ammo: N/A"); UpdateEmptyInventory(playerid,i,string); }
            default: { 
format(string,sizeof(string),"Ammo: %i",PlayerWeapon[playerid][i][P_Ammo]); UpdateInventory(playeridiGetGunObjectID(PlayerWeapon[playerid][i][P_WeaponID]),string); }
        }
    } 
Quote:

[00:20:47] [debug] #2 000300d4 in ?? (0, 6139636, 0, 0, 0, 8, 0, 6139636, 0, 0, ... <1073741813 arguments>) from test.amx
[00:20:47] [debug] #3 00007fbc in public OnPlayerCommandText (0, 6139636) from test.amx

Reply
#2

Compile your script using this:
https://github.com/Zeex/samp-plugin-...ith-debug-info

And then reproduce the error, and post the console log.
It should print out more information.
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Compile your script using this:
https://github.com/Zeex/samp-plugin-...ith-debug-info

And then reproduce the error, and post the console log.
It should print out more information.
The errors I have posted are with that.
PHP код:
[01:10:04] [debugRun time error 4"Array index out of bounds"
[01:10:04] [debug]  Accessing element at index 12 past array upper bound 11
[01:10:04] [debugAMX backtrace:
[
01:10:04] [debug#0 000513ec in ?? (0, 6139916, 0) from test.amx
[01:10:04] [debug#1 0002e338 in ?? (0, 6139876, 0) from test.amx
[01:10:04] [debug#2 000301f4 in ?? (0, 6139876, 0, 0, 0, 8, 0, 6139876, 0, 0, ... <1073741813 arguments>) from test.amx
[01:10:04] [debug#3 000080dc in public OnPlayerCommandText (0, 6139876) from test.amx 
Reply
#4

Here is the mistake:
Код:
new PlayerText:TXT_TD_Text[MAX_PLAYERS][ 12 ]; 
new PlayerWeapon[MAX_PLAYERS][13][P_WEAPONS]; 

for (new i = 0; i <= 12; i++) { 
        PlayerTextDrawSetPreviewRot(playerid,TXT_TD_Update[playerid][ i ], 0,0,0, 5.0);
You defined TXT_TD_Text as a 2D array, 2nd dim. is 12 cells in size, ranging from 0..11 inclusive and you try to access the twelfth slot.
Reply
#5

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
Here is the mistake:
Код:
new PlayerText:TXT_TD_Text[MAX_PLAYERS][ 12 ]; 
new PlayerWeapon[MAX_PLAYERS][13][P_WEAPONS]; 

for (new i = 0; i <= 12; i++) { 
        PlayerTextDrawSetPreviewRot(playerid,TXT_TD_Update[playerid][ i ], 0,0,0, 5.0);
You defined TXT_TD_Text as 12 cells in size, ranging from 0..11 inclusive and you try to access the twelfth slot.
Ah ye lol, didnt even notice. Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)