Jump to content
  • 0

Problema raport automat


Penelope

Question

Am facut sistemul de raport, totul mergee perfect, nu imi da eroare, dar cand sa pornesc server-ul sa testez daca merge bine primesc in consola aceasta eroare:

[debug] Run time error 4: "Array index out of bounds" [debug] Attempted to read/write array element at index 6 in array of size 6 [debux] AMX backtrace: [debug] #0 001a4858 in public RaportPoints (0) in .......amx [debug] #1001a43e8 in public pc_cmd_raport (0, 73597068) in .......amx

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Acum 4 minute, Penelope a spus:

Am facut sistemul de raport, totul mergee perfect, nu imi da eroare, dar cand sa pornesc server-ul sa testez daca merge bine primesc in consola aceasta eroare:

[debug] Run time error 4: "Array index out of bounds" [debug] Attempted to read/write array element at index 6 in array of size 6 [debux] AMX backtrace: [debug] #0 001a4858 in public RaportPoints (0) in .......amx [debug] #1001a43e8 in public pc_cmd_raport (0, 73597068) in .......amx

Ai un array cu 6 elemete respectiv pozitiile 0-5  si tu vrei sa scrii sau sa citesti elementul 7 respectiv pozitia 6. Verifica arrayurile din RaportPoints

Link to comment
Share on other sites

  • 0
Acum 50 minute, valivaly96 a spus:

Ai un array cu 6 elemete respectiv pozitiile 0-5  si tu vrei sa scrii sau sa citesti elementul 7 respectiv pozitia 6. Verifica arrayurile din RaportPoints

Nu prea imi dau seama unde am array-urile alea.

 

Link to comment
Share on other sites

  • 0
Acum 7 ore, Penelope a spus:

Nu prea imi dau seama unde am array-urile alea.

 

Acele array-uri sunt de genu'
new RaportPoints [7]; si tu doar ai folosit 6

Daca nu mai ai nevoie de 7-lea ala poti sa pui

new RaportPoints[6];
Si gata problema !
 

Link to comment
Share on other sites

  • 0
Acum 1 oră, [El.Capo] a spus:

Acele array-uri sunt de genu'
new RaportPoints [7]; si tu doar ai folosit 6

Daca nu mai ai nevoie de 7-lea ala poti sa pui

new RaportPoints[6];
Si gata problema !
 

De fapt exact asta e problema lui. Are nevoie de 7+ nu de 6

Un array incepe de la 0 si faptul ca el are de 6(0-5) si incearca sa acceseze 6 ii da eroarea. 

Link to comment
Share on other sites

  • 0

Problema este ca nu am array-ul asta adaugat

Comenzile pe care le-am folosit:

CMD:setraport(playerid, params[]) {
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, -1, "Nu esti lider!");
    new rank, cmds, string[200], fid = PlayerInfo[playerid][pLeader];
    if(sscanf(params, "ii", rank, cmds)) {
		SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/setraport <rank> <points>");
		format(string, sizeof(string), "Rank 1: %d | Rank 2: %d | Rank 3: %d | Rank 4: %d | Rank 5: %d | Rank 6: %d",
		DynamicFactions[fid][fCommands][0], DynamicFactions[fid][fCommands][1], DynamicFactions[fid][fCommands][2], DynamicFactions[fid][fCommands][3],
	 	DynamicFactions[fid][fCommands][4], DynamicFactions[fid][fCommands][5]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		return 1;
	}
	if(rank < 1 || rank > 6) return SendClientMessage(playerid, -1, "Rank invalid! (1-6)");
    format(string, sizeof(string), "Ai setat cu succes numarul de comenzi la rank %d in %d.", rank, cmds);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    DynamicFactions[fid][fCommands][rank-1] = cmds;
	new query[200];
	format(query, sizeof(query), "UPDATE `factions` SET `Commands%d`='%d' WHERE `ID`='%d'", rank, cmds, fid);
	mysql_query(SQL, query);
	return 1;
}

CMD:resetraport(playerid, params[]) {
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, -1, "Nu esti lider!");
    new fid = PlayerInfo[playerid][pLeader];
    foreach(Player, i) {
        if(IsPlayerConnected(i) && PlayerInfo[i][pMember] == fid) {
 			SendClientMessage(playerid, COLOR_YELLOW, "Raport-ul factiunii a fost resetat!");
 			PlayerInfo[i][pCommands] = 0;
		}
    }
    new query[200];
    format(query, sizeof(query), "UPDATE `users` SET `Commands`='0' WHERE `Member`='%d'",  fid);
    mysql_query(SQL, query);
	return 1;
}

CMD:raport(playerid, params[]) {
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pMember] == 0) return SendClientMessage(playerid, -1, "Nu esti membrul al unei factiuni!!");
	new string[300], fid = PlayerInfo[playerid][pMember];
	SendClientMessage(playerid, -1, "---- Raport ----");
	format(string, sizeof(string), "Factiune: %s", NumeFactiune(fid));
	SendClientMessage(playerid, -1, string);
	format(string, sizeof(string), "Rank: %d", PlayerInfo[playerid][pRank]);
	SendClientMessage(playerid, -1, string);
	format(string, sizeof(string), "Puncte raport: %d/%d", PlayerInfo[playerid][pCommands], RaportPoints(playerid));
	SendClientMessage(playerid, -1, string);
	new text[80];
	if(PlayerInfo[playerid][pCommands] >= RaportPoints(playerid)) text = "{33FF00}Terminat";
	else text = "{FF0000}Neterminat";
	format(string, sizeof(string), "Status raport: %s", text);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, "-----------------");
	SendClientMessage(playerid, -1, string);
	return 1;
}
function AddRaportPoint(playerid) {

	PlayerInfo[playerid][pCommands] ++;
	new query[200];
	format(query, sizeof(query), "UPDATE `users` SET `Commands`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pCommands], PlayerInfo[playerid][pSQLID]);
	mysql_query(SQL, query);
	return 1;
}

function RaportPoints(playerid) {
	new x, fid = PlayerInfo[playerid][pMember], rank = PlayerInfo[playerid][pRank];
	x = DynamicFactions[fid][fCommands][rank-1];
	return x;
}

 

Link to comment
Share on other sites

  • 0
Acum 1 oră, Penelope a spus:

Problema este ca nu am array-ul asta adaugat

Comenzile pe care le-am folosit:

CMD:setraport(playerid, params[]) {
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, -1, "Nu esti lider!");
    new rank, cmds, string[200], fid = PlayerInfo[playerid][pLeader];
    if(sscanf(params, "ii", rank, cmds)) {
		SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/setraport <rank> <points>");
		format(string, sizeof(string), "Rank 1: %d | Rank 2: %d | Rank 3: %d | Rank 4: %d | Rank 5: %d | Rank 6: %d",
		DynamicFactions[fid][fCommands][0], DynamicFactions[fid][fCommands][1], DynamicFactions[fid][fCommands][2], DynamicFactions[fid][fCommands][3],
	 	DynamicFactions[fid][fCommands][4], DynamicFactions[fid][fCommands][5]);
		SendClientMessage(playerid, COLOR_YELLOW, string);
		return 1;
	}
	if(rank < 1 || rank > 6) return SendClientMessage(playerid, -1, "Rank invalid! (1-6)");
    format(string, sizeof(string), "Ai setat cu succes numarul de comenzi la rank %d in %d.", rank, cmds);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    DynamicFactions[fid][fCommands][rank-1] = cmds;
	new query[200];
	format(query, sizeof(query), "UPDATE `factions` SET `Commands%d`='%d' WHERE `ID`='%d'", rank, cmds, fid);
	mysql_query(SQL, query);
	return 1;
}

CMD:resetraport(playerid, params[]) {
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pLeader] == 0) return SendClientMessage(playerid, -1, "Nu esti lider!");
    new fid = PlayerInfo[playerid][pLeader];
    foreach(Player, i) {
        if(IsPlayerConnected(i) && PlayerInfo[i][pMember] == fid) {
 			SendClientMessage(playerid, COLOR_YELLOW, "Raport-ul factiunii a fost resetat!");
 			PlayerInfo[i][pCommands] = 0;
		}
    }
    new query[200];
    format(query, sizeof(query), "UPDATE `users` SET `Commands`='0' WHERE `Member`='%d'",  fid);
    mysql_query(SQL, query);
	return 1;
}

CMD:raport(playerid, params[]) {
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to login first.");
    if(PlayerInfo[playerid][pMember] == 0) return SendClientMessage(playerid, -1, "Nu esti membrul al unei factiuni!!");
	new string[300], fid = PlayerInfo[playerid][pMember];
	SendClientMessage(playerid, -1, "---- Raport ----");
	format(string, sizeof(string), "Factiune: %s", NumeFactiune(fid));
	SendClientMessage(playerid, -1, string);
	format(string, sizeof(string), "Rank: %d", PlayerInfo[playerid][pRank]);
	SendClientMessage(playerid, -1, string);
	format(string, sizeof(string), "Puncte raport: %d/%d", PlayerInfo[playerid][pCommands], RaportPoints(playerid));
	SendClientMessage(playerid, -1, string);
	new text[80];
	if(PlayerInfo[playerid][pCommands] >= RaportPoints(playerid)) text = "{33FF00}Terminat";
	else text = "{FF0000}Neterminat";
	format(string, sizeof(string), "Status raport: %s", text);
	SendClientMessage(playerid, -1, string);
	SendClientMessage(playerid, -1, "-----------------");
	SendClientMessage(playerid, -1, string);
	return 1;
}
function AddRaportPoint(playerid) {

	PlayerInfo[playerid][pCommands] ++;
	new query[200];
	format(query, sizeof(query), "UPDATE `users` SET `Commands`='%d' WHERE `ID`='%d'", PlayerInfo[playerid][pCommands], PlayerInfo[playerid][pSQLID]);
	mysql_query(SQL, query);
	return 1;
}

function RaportPoints(playerid) {
	new x, fid = PlayerInfo[playerid][pMember], rank = PlayerInfo[playerid][pRank];
	x = DynamicFactions[fid][fCommands][rank-1];
	return x;
}

 

pune linia unde e defininita in enum variabila fCommands

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.

Guest
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.