Jump to content
  • 0

Eroare in SA-MP dedicated server

Alexandru Alex


[debug] Run time error 4: "Array index out of bounds"
[debug]  Attempted to read/write array element at index 15 in array of size 15
[debug] AMX backtrace:
[debug] #0 0007f538 in public LoadDynamicFactions () in GM.amx


function LoadDynamicFactions() {
	factionss = cache_num_rows();
	new string[300];
	for(new i = 1; i <= factionss; i++){
		new f = i - 1;
		DynamicFactions[i][fID]                 = cache_get_field_content_int(f, "ID");
		cache_get_field_content(f, "Name", DynamicFactions[i][fName], SQL, 64);
		DynamicFactions[i][fcX]                 = cache_get_field_content_float(f, "X");
   	    DynamicFactions[i][fcY]                 = cache_get_field_content_float(f, "Y");
    	DynamicFactions[i][fcZ]                 = cache_get_field_content_float(f, "Z");
    	DynamicFactions[i][fceX]                = cache_get_field_content_float(f, "eX");
   	    DynamicFactions[i][fceY]                = cache_get_field_content_float(f, "eY");
    	DynamicFactions[i][fceZ]                = cache_get_field_content_float(f, "eZ");
    	DynamicFactions[i][fSafePos][0]			= cache_get_field_content_float(f, "SafePos1");
    	DynamicFactions[i][fSafePos][1]			= cache_get_field_content_float(f, "SafePos2");
    	DynamicFactions[i][fSafePos][2]			= cache_get_field_content_float(f, "SafePos3");
		DynamicFactions[i][fMats]               = cache_get_field_content_int(f, "Mats");
		DynamicFactions[i][fDrugs]              = cache_get_field_content_int(f, "Drugs");
		DynamicFactions[i][fInterior]           = cache_get_field_content_int(f, "Interior");
    	DynamicFactions[i][fVirtual]            = cache_get_field_content_int(f, "Virtual");
    	DynamicFactions[i][fMapIcon]            = cache_get_field_content_int(f, "MapIcon");
    	DynamicFactions[i][fLocked]            	= cache_get_field_content_int(f, "Locked");
		DynamicFactions[i][fBank]               = cache_get_field_content_int(f, "Bank");
		DynamicFactions[i][fPickupIDD]          = cache_get_field_content_int(f, "PickupID");
		cache_get_field_content(f, "Anunt", DynamicFactions[i][fAnn], SQL, 128);
		DynamicFactions[i][fMaxMembers]         = cache_get_field_content_int(f, "MaxMembers");
		DynamicFactions[i][fMinLevel]         	= cache_get_field_content_int(f, "MinLevel");
		DynamicFactions[i][fApplication]        = cache_get_field_content_int(f, "Application");
		cache_get_field_content(f, "Rank1", DynamicFactions[i][fRankName1], SQL, 64);
		cache_get_field_content(f, "Rank2", DynamicFactions[i][fRankName2], SQL, 64);
		cache_get_field_content(f, "Rank3", DynamicFactions[i][fRankName3], SQL, 64);
		cache_get_field_content(f, "Rank4", DynamicFactions[i][fRankName4], SQL, 64);
		cache_get_field_content(f, "Rank5", DynamicFactions[i][fRankName5], SQL, 64);
		cache_get_field_content(f, "Rank6", DynamicFactions[i][fRankName6], SQL, 64);
		cache_get_field_content(f, "Rank7", DynamicFactions[i][fRankName7], SQL, 64);
		for(new c; c < 10; c++) {
			new s[10];
			format(s, sizeof(s),"Skin%d",c);
			FactionSkin[i][c] = cache_get_field_content_int(f, s);
		switch(DynamicFactions[i][fLocked]) {
	    	case 0: format(string, sizeof(string), "{008080}Faction:{FFFFFF} %d\n{008080}Name:{FFFFFF} %s\n{008080}HQ Status:{FFFFFF} (unlocked)",i, DynamicFactions[i][fName]);
	    	case 1: format(string, sizeof(string), "{008080}Faction:{FFFFFF} %d\n{008080}Name:{FFFFFF} %s\n{008080}HQ Status:{FFFFFF} (locked)",i, DynamicFactions[i][fName]);
	   	DynamicFactions[i][fPickupID] = CreateDynamicPickup(DynamicFactions[i][fPickupIDD], 23, DynamicFactions[i][fceX], DynamicFactions[i][fceY], DynamicFactions[i][fceZ], 0, -1, -1, 10);
		DynamicFactions[i][fLabelID] = CreateDynamic3DTextLabel(string, -1, DynamicFactions[i][fceX], DynamicFactions[i][fceY], DynamicFactions[i][fceZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 25.0);
		if(DynamicFactions[i][fMapIcon] != 0) CreateDynamicMapIcon(DynamicFactions[i][fceX],DynamicFactions[i][fceY],DynamicFactions[i][fceZ],DynamicFactions[i][fMapIcon],0,-1,-1,-1,750.0); //Bank
		format(string, sizeof(string), "%s\nGroup Safe", DynamicFactions[i][fName]);
		DynamicFactions[i][fSafePickupID] = CreateDynamicPickup(1274, 23, DynamicFactions[i][fSafePos][0], DynamicFactions[i][fSafePos][1], DynamicFactions[i][fSafePos][2], DynamicFactions[i][fVirtual], DynamicFactions[i][fInterior], -1, 50);
		DynamicFactions[i][fSafeLabelID] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, DynamicFactions[i][fSafePos][0], DynamicFactions[i][fSafePos][1], DynamicFactions[i][fSafePos][2], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, DynamicFactions[i][fVirtual], DynamicFactions[i][fInterior], -1, 20.0);
	printf("Loading %d groups.", factionss);
	return 1;


Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Problema ta e aici

for(new i = 1; i <= factionss; i++)

Si faptul ca accesezi DynamicFactions cu i

Indexul incepe mereu de la 0, daca tu ai 15 la DynamicFactions asta inseamna ca ai 15 factiuni, dar nu inseamna si ca DynamicFactions[15] este valid

Ai 2 posibilitati, ori faci DynamicFactions 16 ori faci i = 0 si il folosesti in loc de f pentru mysql si pentru factiuni(si stergi f) si

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

Asa functioneaza array-urile (matriciile), incep de la 0 si termina la valoarea definita - 1

Edited by Banditul
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.