#1

Hello, i've added a cmd (/offlinestats)

When i use this command, it doesn't work and it shows this in the logs

Код:
[05:35:11] [debug] Run time error 4: "Array index out of bounds"
[05:35:11] [debug]  Accessing element at index 420 past array upper bound 99
[05:35:11] [debug] AMX backtrace:
[05:35:11] [debug] #0 0011d230 in public LoadStats (0, 4770352) from UoS.amx
And it doesn't show anything at mysql logs

Here you are the loadstats and loadstats2 code

Load stats>>>>
Код:
function LoadStats(playerid, PlayersName[])
{
	if(!MySQL_rowCount())
	{
		format(str, sizeof(str), ""RED_E"[ERROR] "GREY_E"Account '%s' does not exist.", PlayersName);
		SendClientMessage(playerid, COLOR_GREY, str);
	}
	else
	{
		pAdmin[p3] = MySQL_getInt(0, 0);
		pTotalHours[p3] = MySQL_getInt(0, 1);
		pTotalMinutes[p3] = MySQL_getInt(0, 2);
		pTotalSeconds[p3] = MySQL_getInt(0, 3);
		pInfo[p3][pKills] = MySQL_getInt(0, 4);
		pInfo[p3][pDeaths] = MySQL_getInt(0, 5);
		pCash[p3] = MySQL_getInt(0, 6);
		pScore[p3] = MySQL_getInt(0, 7);
		pPremium[p3] = MySQL_getInt(0, 8);
		pInfo[p3][pSaveSkin] = MySQL_getInt(0, 9);
		pCookies[p3] = MySQL_getInt(0, 10);
		pInfo[p3][pEventsWon] = MySQL_getInt(0, 11);
		pInfo[p3][pRacesWon] = MySQL_getInt(0, 12);
		pInfo[p3][pMBFound] = MySQL_getInt(0, 13);
 		MySQL_getString(0, 14, pRegDate[p3]);
 		MySQL_getString(0, 15, pLastDate[p3]);
		BankMoney[p3] = MySQL_getInt(0, 16);
		reactionsWon[p3] = MySQL_getInt(0, 17);
		pArrests[p3] = MySQL_getInt(0, 18);
		TotalKillStreak[p3] = MySQL_getInt(0, 19);
		MySQL_getString(0, 20, pDescription[p3]);
		pDuelsWon[p3] = MySQL_getInt(0, 21);
		pFallouts[p3] = MySQL_getInt(0, 22);
		pClanID[p3] = MySQL_getInt(0, 23);
		pClanRank[p3] = MySQL_getInt(0, 24);
		pDerbys[p3] = MySQL_getInt(0, 25);
		pCookieJars[p3] = MySQL_getInt(0, 26);
		pSpawnPlace[p3] = MySQL_getInt(0, 27);
		mathsWon[p3] = MySQL_getInt(0, 28);
		pReportPoints[p3] = MySQL_getInt(0, 29);
		Helper[p3] = MySQL_getInt(0, 30);
		format(query, sizeof(query), "SELECT cName FROM clans WHERE cID=%d", pClanID[p3]);
		MySQL_query(query, true, "LoadStats2", "is", playerid, PlayersName);
	}
	return true;
}
And about loadstats2

Код:
function LoadStats2(playerid, PlayersName[])
{
		// Main Statistics
		if(MySQL_rowCount())
		{
			cache_get_row(0, 0, pClanName[p3]);
		}
		new line4[700];
		new line3[2000];
		new str3[80], str4[80], str7[80], str11[140];
		switch(pAdmin[p3])
		{
	 		case 0:
	   		{
				if(pPremium[p3] > 0)
				{
	   				if(pPremium[p3] == 3)
					{
						if(premiumExpired[p3] != 0) str3 = ""LB2_E"> Status: "LB_E"VIP Player (Temporary)";
						else str3 = ""LB2_E"> Status: "LB_E"VIP Player";
					}
					else
					{
						if(premiumExpired[p3] != 0) format(str3, sizeof(str3), ""LB2_E"> Status: "WHITE_E"Premium Member (Level: %d) (Temp)", pPremium[p3]);
						else format(str3, sizeof(str3), ""LB2_E"> Status: "WHITE_E"Premium Member (Level: %d)", pPremium[p3]);
					}
				}
				else str3 = ""LB2_E"> Status: "WHITE_E"Regular Player";
				if(Helper[p3] != 0) str3 = ""LB2_E"> Status: "GREEN_E"Helper";
			}
			case 1: str3 = ""LB2_E"> Status: "GREEN_E"Trial Administrator";
			case 2: str3 = ""LB2_E"> Status: "LB_E"Administrator";
			case 3: str3 = ""LB2_E"> Status: "YELLOW_E"Super Administrator";
			case 4: str3 = ""LB2_E"> Status: "ORANGE_E"Advanced Administrator";
			case 5: str3 = ""LB2_E"> Status: "DARK_E"Experienced Administrator";
			case 6: str3 = ""LB2_E"> Status: "GREEN_E"Senior Administrator";
			case 7: str3 = ""LB2_E"> Status: "LB_E"Superme Administrator";
			case 8: str3 = ""LB2_E"> Status: "YELLOW_E"Elite Administrator";
			case 9: str3 = ""LB2_E"> Status: "ORANGE_E"Professional Administrator";
			case 10: str3 = ""LB2_E"> Status: "DARK_E"Master Administrator";
			case 11: str3 = ""LB2_E"> Status: "GREEN_E"Lead Administrator";
			case 12: str3 = ""LB2_E"> Status: "LB_E"Head Administrator";
			case 13: str3 = ""LB2_E"> Status: "YELLOW_E"Server Manager";
			case 14: str3 = ""LB2_E"> Status: "ORANGE_E"Head Manager";
			case 15: str3 = ""LB2_E"> Status: "DARK_E"Server Owner";
		}
		if(pHidden[p3] != 0) str3 = ""LB2_E"> Status: "WHITE_E"Regular Player";
		//new pCity[28];
		if(pClanID[p3] != -1)
		{
			format(str11, sizeof(str11), ""LB2_E"> Clan: "WHITE_E"%s "RED_E"|| "LB2_E"Rank: "WHITE_E"%s", pClanName[p3], GangPositions[pClanRank[p3]][E_gang_pos_name]);
		}
		else format(str11, sizeof(str11), ""LB2_E"> Clan: "WHITE_E"None "RED_E"|| "LB2_E"Rank: "WHITE_E"None");
	 	/*GetPlayerCity(p3, pCity, sizeof(pCity));
		format(str9, sizeof(str9), ""LB2_E"> Country: "WHITE_E"%s "RED_E"|| "LB2_E"City: "WHITE_E"%s "RED_E"|| "LB2_E"GMT: "WHITE_E"%d", pCountry[p3], pCity, GetPlayerGMT(p3));*/
		//format(str9, sizeof(str9), ""LB2_E"> Country: "WHITE_E"- "RED_E"|| "LB2_E"City: "WHITE_E"- "RED_E"|| "LB2_E"GMT: "WHITE_E"-");
		format(line4, sizeof(line4), ""WHITEP_E"%s's stats:\n\n{FF4545}Main Statistics:\n%s\n\
		"LB2_E"> Score: "WHITE_E"%d\n"LB2_E"> Cookies: "WHITE_E"%d\n"LB2_E"> Money: "LG_E"$"WHITE_E"%s\n"LB2_E"> Bank Money: "LG_E"$"WHITE_E"%s\n%s\n\n", PlayersName, str3, pScore[p3], pCookies[p3], ToCurrency(pCash[p3]), ToCurrency(BankMoney[p3]), str11);
		strcat(line3, line4);

		/// General Statistics

		if(pTotalHours[p3] == 0)
		{
			if(pTotalMinutes[p3] == 0)
			{
	  			format(str4, sizeof(str4), ""LB2_E"> Total Online Time: "WHITE_E"%d seconds", pTotalSeconds[p3]);
			}
			else format(str4, sizeof(str4), ""LB2_E"> Total Online Time: "WHITE_E"%d minutes and %d seconds", pTotalMinutes[p3], pTotalSeconds[p3]);
		}
		else format(str4, sizeof(str4), ""LB2_E"> Total Online Time: "WHITE_E"%d hours, %d minutes and %d seconds", pTotalHours[p3], pTotalMinutes[p3], pTotalSeconds[p3]);

		format(line4, sizeof(line4), "{FF4545}General Statistics:\n"LB2_E"> Member Since: "WHITE_E"%s\n"LB2_E"> Last Online: "WHITE_E"%s\n%s\n", pRegDate[p3], pLastDate[p3], str4);
		strcat(line3, line4);

		format(line4, sizeof(line4), ""LB2_E"> Kills: "WHITE_E"%d / "LB2_E"Deaths: "WHITE_E"%d "RED_E"|| "LB2_E"KDR: "WHITE_E"%0.2f\n"LB2_E"> Highest Killstreak: "WHITE_E"%d\n\
		\n", pInfo[p3][pKills], pInfo[p3][pDeaths], Float:pInfo[p3][pKills]/Float:pInfo[p3][pDeaths], TotalKillStreak[p3]);
		strcat(line3, line4);

		// Other Statistics
	   	switch(pSpawnPlace[p3])
		{
			case -1: str7 = ""LB2_E"> Spawn Place: "WHITE_E"Random.";
			case 0: str7 = ""LB2_E"> Spawn Place: "WHITE_E"San Fierro";
	 		case 1: str7 = ""LB2_E"> Spawn Place: "WHITE_E"Bayside";
	  		case 2: str7 = ""LB2_E"> Spawn Place: "WHITE_E"Abandoned Airport";
	   		case 3: str7 = ""LB2_E"> Spawn Place: "WHITE_E"Las Venturas Airport";
	    	case 4: str7 = ""LB2_E"> Spawn Place: "WHITE_E"HalfPipe";
	    	case 5: str7 = ""LB2_E"> Spawn Place: "WHITE_E"San Fierro Airport";
	   		case 6: str7 = ""LB2_E"> Spawn Place: "WHITE_E"Own House.";
		}
		format(line4, sizeof(line4), "{FF4545}Other Statistics:\n%s\n"LB2_E"> Skin ID: "WHITE_E"%d\n"LB2_E"> Duels Won: "WHITE_E"%d\n"LB2_E"> Events Won: "WHITE_E"%d\n"LB2_E"> Arrests: "WHITE_E"%d\n\
		"LB2_E"> Races Won: "WHITE_E"%d\n"LB2_E"> Moneybags Found: "WHITE_E"%d\n"LB2_E"> Cookie Jars Found: "WHITE_E"%d\n", str7, GetPlayerSkin(p3), pDuelsWon[p3], pInfo[p3][pEventsWon], pArrests[p3], pInfo[p3][pRacesWon], pInfo[p3][pMBFound], pCookieJars[p3]);
		strcat(line3, line4);

		format(line4, sizeof(line4), ""LB2_E"> Reactions Won: "WHITE_E"%d\n"LB2_E"> Math Quiz's Won: "WHITE_E"%d\n"LB2_E"> Fallouts Won: "WHITE_E"%d\n"LB2_E"> Derbys Won: "WHITE_E"%d\n"LB2_E"> Report Points: "WHITE_E"%d\
		\n\n"LB2_E"> Description:\n   "WHITEP_E"%s\n", reactionsWon[p3], mathsWon[p3], pFallouts[p3], pDerbys[p3], pReportPoints[p3], pDescription[p3]);
		strcat(line3, line4);

		ShowPlayerDialog(playerid, NO_DIALOG, DIALOG_STYLE_MSGBOX, ""ORANGE_E"UoS: "WHITE_E"Offline Statistics", line3, "Close", "");
}
here is the main CMD

Код:
CMD:offlinestats(playerid, params[]) return cmd_ostats(playerid, params);
CMD:ostats(playerid, params[])
{
	if(pLogged[playerid] == false)
	{
	    Error(playerid, "You must be logged in to check statistics!");
	    return true;
	}

	if(sscanf(params, "s[24]", tmp))
	{
	    Usage(playerid, "/ostats <player name>");
 		return true;
 	}

 	foreach(Player, ii)
	{
		GetPlayerName(ii, PlayerName, MAX_PLAYER_NAME);

		if(!strcmp(PlayerName, tmp, true))
		{
			Error(playerid, "Player is online, you can use /stats on them.");
	  		return true;
	  	}
	}

	// Load User Data
    new cVar[500];
    new cQuery[600];

	strcat(cVar, "adminlevel,hours,minutes,seconds,kills,deaths,money,score,premium,saveskin,cookies,events_won,races_won,MB_found,reg_time,last_time,");
	strcat(cVar, "bmoney,rtests,arrests,killstreak,description,duels_won,fallouts,clan_id,clan_rank,derby_wins,cookiejars,spawnplace,maths,report_points,helper");

	new escaped_name[24];
	mysql_real_escape_string(tmp, escaped_name);
	format(cQuery, sizeof(cQuery), "SELECT %s FROM players WHERE name='%s' LIMIT 1", cVar, escaped_name);
	MySQL_query(cQuery, true, "LoadStats", "is", playerid, escaped_name);

	return true;
}
Reply
#2

How "p3" is defined? To get the exact line: https://github.com/Zeex/samp-plugin-...ith-debug-info

By the way why don't you just "SELECT * ..." than selecting 30 columns?
Reply
#3

p3 is already defined
But idk what is the main problem at this?

And here is the compile result
Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          35960 bytes
Code size:          2308452 bytes
Data size:          4771144 bytes
Stack/heap size:      16384 bytes; estimated max. usage: unknown, due to recursion
Total requirements: 7131940 bytes
Reply
#4

I know "p3" is defined, I asked how it is.

All you have to do now (after compiling with debug info) is to reproduce it and post the new logs from crashdetect.
Reply
#5

Here is p3
Код:
new p3 = 420;
And the logs are same
Reply
#6

I thought so. However it doesn't make any sense.

You have to save all those information for each player and display them. You cannot use variables to access data as the player is not connected.
Reply
#7

So what is the main wrong in the code, and how can i fix it?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)