Jump to content
  • 0

Problema raport automat


Question

Posted

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

6 answers to this question

Recommended Posts

  • 0
Posted
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

  • 0
Posted
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.

 

  • 0
Posted
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 !
 

  • 0
Posted
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. 

  • 0
Posted

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;
}

 

  • 0
Posted
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.