Jump to content
  • 0

Array of index out of bounds


newbie.

Question

Problema intalnita (descriere): Imi da run time errorul ala cu array of index out of bounds cand folosesc doar 5 comenzi din gm, in legatura cu dealershipul.
Ero(area / rile) / warning-(ul / urile): 

[10:52:08] [debug] Run time error 4: "Array index out of bounds" // asta e de la una
[10:52:08] [debug]  Accessing element at index 462 past array upper bound 100
[10:52:08] [debug] AMX backtrace:
[10:52:08] [debug] #0 001e7e6c in public cmd_edittype (0, 3803424) from vx-rp2.amx
[10:52:08] [debug] #1 native CallLocalFunction () from samp-server.exe
[10:52:08] [debug] #2 000009d0 in public OnPlayerCommandText (0, 3803360) from vx-rp2.amx
[10:52:11] [server] [cmd] noob (ID 0): /buycar
[10:52:18] [server] [cmd] noob (ID 0): /stats
[10:52:23] [server] [cmd] noob (ID 0): /vehicles
[10:57:25] [server] [cmd] noob (ID 0): /dscars
[10:57:25] [debug] Run time error 4: "Array index out of bounds" // de la alta, si tot asa
[10:57:25] [debug]  Accessing element at index 101 past array upper bound 100
[10:57:25] [debug] AMX backtrace:
[10:57:25] [debug] #0 001e79c4 in public cmd_dscars (0, 3803392) from vx-rp2.amx
[10:57:25] [debug] #1 native CallLocalFunction () from samp-server.exe
[10:57:25] [debug] #2 000008cc in public OnPlayerCommandText (0, 3803360) from vx-rp2.amx


Liniile de cod / sursa / script-ul(obligatoriu): 

CMD:dscars(playerid, params[])
{
	if(playerVariables[playerid][pAdminLevel] >= 6)
	{
		for(new i = 0; i <= MAX_DEALERSHIP_CARS; i++)
		{
			if(strlen(dealerVariables[i][dCarName]) >= 1)
			{
				format(szMessage, sizeof(szMessage), "Dealer ID: %d | Car ID: %d | Name: %s | Price: %s | Stock: %d", dealerVariables[i][dCarID], i, dealerVariables[i][dCarName], NumberFormat(dealerVariables[i][dCarPrice]), dealerVariables[i][dCarStock]);
				SendClientMessage(playerid, -1, szMessage);
			}
		}
	}
	return 1;
}

CMD:editprice(playerid, params[])
{
	new carid, price;
	if(sscanf(params, "ii", carid, price)) return SendClientMessage(playerid, -1, "Syntax: /editprice [carid] [price]");
	if(playerVariables[playerid][pAdminLevel] >= 6)
	{
		dealerVariables[carid][dCarPrice] = price;
		format(szMessage, sizeof(szMessage), "You have changed car %d's price to %d", carid, price);
		SendClientMessage(playerid, -1, szMessage);
		saveCar(carid);
	}
	return 1;
}

CMD:edittype(playerid, params[])
{
	new carid, type;
	if(sscanf(params, "ii", carid, type)) return SendClientMessage(playerid, -1, "Syntax: /edittype [carid] [type]");
	if(playerVariables[playerid][pAdminLevel] >= 6)
	{
		dealerVariables[carid][dCarType] = type;
		format(szMessage, sizeof(szMessage), "You have changed car %d's type to %d", carid, type);
		SendClientMessage(playerid, -1, szMessage);
		saveCar(carid);
	}
	return 1;
}

CMD:editmodel(playerid, params[])
{
	new carid, model;
	if(sscanf(params, "ii", carid, model)) return SendClientMessage(playerid, -1, "Syntax: /editmodel [carid] [model]");
	if(playerVariables[playerid][pAdminLevel] >= 6)
	{
		dealerVariables[carid][dCarID] = model;
		format(szMessage, sizeof(szMessage), "You have changed car %d's model to %d", carid, model);
		SendClientMessage(playerid, -1, szMessage);
		saveCar(carid);
	}
	return 1;
}

CMD:editname(playerid, params[])
{
	new carid, name[255];
	if(sscanf(params, "is[255]", carid, name)) return SendClientMessage(playerid, -1, "Syntax: /editname [carid] [name]");
	if(playerVariables[playerid][pAdminLevel] >= 6)
	{
		format(dealerVariables[carid][dCarName], 225, name);
		format(szMessage, sizeof(szMessage), "You have changed car %d's name to %s", carid, dealerVariables[carid][dCarName]);
		SendClientMessage(playerid, -1, szMessage);
		saveCar(carid);
	}
	return 1;
}

enum pt ds:

enum dInfo
{
	dCarID,
	dCarName[255],
	dCarStock,
	dCarPrice,
	dCarType, // 1 - cheap vehicles; 2 - normal vehicles; 3 - expensive vehicles;
}
new dealerVariables[MAX_DEALERSHIP_CARS][dInfo];

MAX_DEALERSHIP_CARS e 101. (#define MAX_DEALERSHIP_CARS 101)


Imagini / Video (optional): - 
Ati incercat sa rezolvati singur?:  habar nu am de ce imi face asa.

Edited by newbie.
Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
  • 0
Acum 58 minute, WiDuAlK a spus:

pune crashdetect si nativechecker, apoi reposteaza problemele.

am crashdetect pus si nativechecker, tot aia imi da cu ambele

plugins crashdetect sscanf streamer mysql GeoIP_Plugin nativechecker

///// edit: am repus astea si acum imi da asa:

[14:46:58] [debug] Run time error 4: "Array index out of bounds"
[14:46:58] [debug]  Accessing element at index 462 past array upper bound 100
[14:46:58] [debug] AMX backtrace:
[14:46:58] [debug] #0 00273f14 in public cmd_edittype (playerid=0, params[][email protected] "462 1") at C:\Users\user\Desktop\pawn project\gamemodes\vx-rp2.pwn:41577
[14:46:58] [debug] #1 native CallLocalFunction () from samp-server.exe
[14:46:58] [debug] #2 00000bb0 in public OnPlayerCommandText (playerid=0, cmdtext[][email protected] "/edittype 462 1") at C:\Users\user\Desktop\pawn project\pawno\include\zcmd.inc:108
 

linia:

        dealerVariables[carid][dCarType] = type;

comanda:

CMD:edittype(playerid, params[])
{
    new carid, type;
    if(sscanf(params, "ii", carid, type)) return SendClientMessage(playerid, -1, "Syntax: /edittype [carid] [type]");
    if(playerVariables[playerid][pAdminLevel] >= 6)
    {
        dealerVariables[carid][dCarType] = type;
        format(szMessage, sizeof(szMessage), "You have changed car %d's type to %d", carid, type);
        SendClientMessage(playerid, -1, szMessage);
        saveCar(carid);
    }
    return 1;
}


Edited  by newbie.

Link to comment
Share on other sites

  • 0
  • 0
Acum 5 minute, WiDuAlK a spus:

:|  in mod normal trebuia sa te trimita la linia cu problema, dar vad ca nu te trimite. Fa-i update la crashdetect. Trebuie s aiti arate linia problema.

linia:

        dealerVariables[carid][dCarType] = type;
 

comanda:

CMD:edittype(playerid, params[])

	{

	    new carid, type;

	    if(sscanf(params, "ii", carid, type)) return SendClientMessage(playerid, -1, "Syntax: /edittype [carid] [type]");

	    if(playerVariables[playerid][pAdminLevel] >= 6)

	    {

	        dealerVariables[carid][dCarType] = type;

	        format(szMessage, sizeof(szMessage), "You have changed car %d's type to %d", carid, type);

	        SendClientMessage(playerid, -1, szMessage);

	        saveCar(carid);

	    }

	    return 1;

	}
Link to comment
Share on other sites

  • 0
  • 0
Acum 16 minute, WiDuAlK a spus:

sterge

dealerVariables[carid][dCarType] = type;

si fa-i debugg cu rezultatul obtinut.

JT3Awoc.png

cod 
print("edittype: edit the type of car (1)");
        format(szMessage, sizeof(szMessage), "You have changed car %d's type to %d", carid, type);
        print("edittype: edit the type of car (mesajul)");
        SendClientMessage(playerid, -1, szMessage);
        print("edittype: edit the type of car (trimite mesajul)");
        saveCar(carid);
        print("edittype: edit the type of car (salveaza masina)");

deci problema e undeva la saveCar

 

savecar:

stock saveCar(const id)

	{

	    if(dealerVariables[id][dCarPrice] >= 1)

	    {

	        mysql_format(handle, szLargeString, sizeof(szLargeString), "UPDATE `dealer` SET `CarPrice` = '%d', `CarNormID` = '%d', `CarName` = '%e', `CarStock` = '%d', `CarType` = '%d' WHERE `CarID` = '%d'", dealerVariables[id][dCarPrice], dealerVariables[id][dCarID], dealerVariables[id][dCarName], dealerVariables[id][dCarStock], dealerVariables[id][dCarType],id);

	        mysql_tquery(handle, szLargeString);

	    }

	    else

	    {

	        return 0;

	    }

	    

	    return 1;

	}
 

 

Edited by newbie.
Link to comment
Share on other sites

  • 0
  • 0
Guest
This topic is now closed to further replies.
×
×
  • 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.