Run Time Error 4
#1

Hi,
I'm italian. Excuse me for my bad english.
I have a problem with my GameMode RolePlay, this problem is caused by a stock of LoadHouse. This is the code:

Код:
stock LoadHouse()
{
new Nome[MAX_PLAYER_NAME];
new Desc[64];
for(new i = 0; i<MAX_HOUSE; i++)
{
for(new a = 0; a<MAX_PLAYERS; a++)
{
format(file, sizeof(file), H_FILE_PATH, i);
if(INI_Exist(file))
{
INI_Open(file);
hInfo[i][X] = INI_ReadFloat("FloatX");
hInfo[i][Y] = INI_ReadFloat("FloatY");
hInfo[i][Z] = INI_ReadFloat("FloatZ");
hInfo[i][Xu] = INI_ReadFloat("FloatXUscita");
hInfo[i][Yu] = INI_ReadFloat("FloatYUscita");
hInfo[i][Zu] = INI_ReadFloat("FloatZUscita");
INI_ReadString(Desc, "Descrizione", 128);
hInfo[i][hText] = Desc;
hInfo[i][hCosto] = INI_ReadInt("CostoCasa");
hInfo[i][Interior] = INI_ReadInt("Interior");
hInfo[i][VirtualW] = INI_ReadInt("VirtualW");
hInfo[i][Comprata] = INI_ReadInt("Comprata");
hInfo[i][Cassaforte] = INI_ReadInt("Cassaforte");
hInfo[i][Chiusa] = INI_ReadInt("Chiusa");
INI_ReadString(Nome, "Proprietario", 128);
hInfo[i][Proprietario] = Nome;
INI_Close();
if(hInfo[i][Comprata] == 0)
{
//CreateDynamicPickup(modelid, type, Float:x, Float:y, Float:z, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
PickupID[i] = CreateDynamicPickup(1273, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], -1, GetPlayerInterior(i), -1, 15.0);
MapIconID[i] = CreateDynamicMapIcon(hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 31, 0, 0, 0, a, 10.0);
new stringatext[128];
format(stringatext, sizeof(stringatext), "[ID: %d] Casa in Vendita. Costo: $%d.", i, hInfo[i][hCosto]);
hInfo[i][DText] = CreateDynamic3DTextLabel(stringatext, BIANCO, hInfo[GetH(i)][X], hInfo[GetH(i)][Y], hInfo[GetH(i)][Z], 8.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
}
else if(hInfo[i][Comprata] == 1)
{
//CreateDynamicPickup(modelid, type, Float:x, Float:y, Float:z, worldid = -1, interiorid = -1, playerid = -1, Float:distance = 100.0);
PickupID[i] = CreateDynamicPickup(1272, 24, hInfo[i][X], hInfo[i][Y], hInfo[i][Z], -1, GetPlayerInterior(i), -1, 15.0);
MapIconID[i] = CreateDynamicMapIcon(hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 32, 0, 0, 0, a, 10.0);
new stringatext[128];
format(stringatext, sizeof(stringatext), "[ID: %d] Casa non in Vendita. Proprietario: %s.", i, hInfo[i][Proprietario]);
hInfo[i][DText] = CreateDynamic3DTextLabel(stringatext, BIANCO, hInfo[GetH(i)][X], hInfo[GetH(i)][Y], hInfo[GetH(i)][Z], 8.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
}
}
}
}
}
The Pawn have not error and warning, i start the samp-server and show this:

Thanks for all reply.
Reply
#2

for(new i = 0; i<MAX_HOUSE; i++)

hInfo size?

--
Dammi la riga dove definisci hInfo.
Reply
#3

La definisco sotto l'enum.
Код:
enum HouseInfo
{
        Float:X,
        Float:Y,
        Float:Z,
        Float:Xu,
        Float:Yu,
        Float:Zu,
        hText[64],
        hCosto,
        Interior,
        VirtualW,
        Proprietario[24],
        Comprata,
        Chiusa,
        Cassaforte,
        Text3D:DText,
}
new hInfo[MAX_HOUSE][HouseInfo];
Reply
#4

Compile your gamemode with debug flags so we can have more informations from the error
Anyway the problem might be here for(new a = 0; a<MAX_PLAYERS; a++)
You use "a" in an array?

--

Compila la tua gamemode con la modalitа debug (crea un file pawn.cfg nella cartella di pawn e aggiungici -d3) cosi quando esce l'errore ti da piщ informazioni
dopo averlo fatto copia quello che ti и uscito nel server.log

Per caso usi "a" in qualche array nel codice? Non mi va di guardare tutto il codice
Reply
#5

Ho fatto ciт che mi hai richiesto con il file .cfg e in server_log mi и uscito cosi:

Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x, ©2005-2013 SA-MP Team

[18:13:26] filterscripts = ""  (string)
[18:13:26] 
[18:13:26] Server Plugins
[18:13:26] --------------
[18:13:26]  Loading plugin: mysql
[18:13:26] 

  > MySQL plugin R6-2 successfully loaded.

[18:13:26]   Loaded.
[18:13:26]  Loading plugin: sscanf
[18:13:26] 

[18:13:26]  ===============================

[18:13:26]       sscanf plugin loaded.     

[18:13:26]    © 2009 Alex "******" Cole

[18:13:26]    0.3d-R2 500 Players "dnee"

[18:13:26]  ===============================

[18:13:26]   Loaded.
[18:13:26]  Loading plugin: streamer
[18:13:26] 

*** Streamer Plugin v2.6 by Incognito loaded ***

[18:13:26]   Loaded.
[18:13:26]  Loaded 3 plugins.

[18:13:26] 
[18:13:26] Filterscripts
[18:13:26] ---------------
[18:13:26]   Loaded 0 filterscripts.

[18:13:26] [Comunicazione:] Connessione MySQL Stabilita con Successo.
[18:13:26] 
BC:RP CreekSide 1.0 - www.onezure.it

[18:13:26] Caricamento case in corso..
[18:13:26] Script[gamemodes/creekside.amx]: Run time error 4: "Array index out of bounds"
[18:13:26] Number of vehicle models: 0
Console input: exit
[18:13:29] --- Server Shutting Down.
[18:13:29] 

  > MySQL plugin unloaded.

[18:13:29] 

[18:13:29]  ===============================

[18:13:29]      sscanf plugin unloaded.    

[18:13:29]  ===============================

[18:13:29] 

*** Streamer Plugin v2.6 by Incognito unloaded ***
Nessuna cosa in piщ.
La variabile 'a' la utilizzo qui:
Код:
for(new a = 0; a<MAX_PLAYERS; a++)
Reply
#6

1) This is an English forum, so speak English. Otherwise, go to your language's board.

2) The error is straight forward - you have an array that is out of bounds (a cell is being accessed that does not exist in that array). Go through the code checking all the arrays. Use debugging to print the value you are trying to access from them and check if it is greater than that of the size they were defined with.
Reply
#7

Excuse me for my language, other users in this topic are Italian.
Ehm.. the debug are applied, and the server_log are up on your reply. And.. the error are on LoadHouse.

Excuse me for my bad english.
Reply
#8

No, you need to add in your own debugging to check what element is being accessed in the arrays. For example, you have this line:
pawn Код:
MapIconID[i] = CreateDynamicMapIcon(hInfo[i][X], hInfo[i][Y], hInfo[i][Z], 31, 0, 0, 0, a, 10.0);
Before that, add a print statement to check the value of "i" and if it exceeds the declaration size of MapIconID array:
pawn Код:
printf("Value of \"i\" accessing \"MapIconID\" - %i", i);
Reply
#9

The Code is BIG. I create printf for all code? What That Fuck? O.O
Reply
#10

No, I just like reading my own posts.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)