crashdetect bugs
#1

Hy all!

Codes:

OnPlayerConnect bug:

Код:
[10:13:49] [debug] Run time error 4: "Array index out of bounds"
[10:13:49] [debug]  Accessing element at index 1024 past array upper bound 1023
[10:13:49] [debug] AMX backtrace:
[10:13:49] [debug] #0 00005360 in ?? (1132953600, 1135443968, 1120206848, 1091766845, 1085827327, 1120403456) from lvrp.amx
[10:13:49] [debug] #1 000457f0 in public SSCANF_OnPlayerConnect (0) from lvrp.amx
[10:13:49] [debug] #2 0000ca38 in public MP_OPC (0) from lvrp.amx
[10:13:49] [debug] #3 native CallLocalFunction () from samp-server.exe
[10:13:49] [debug] #4 00009d20 in public _y_utils_OnPlayerConnect (0) from lvrp.amx
[10:13:49] [debug] #5 000049a4 in public OnPlayerConnect (0) from lvrp.amx
OnPlayerKeyStateChange:

Код:
[10:14:18] [debug] Run time error 4: "Array index out of bounds"
[10:14:18] [debug]  Accessing element at negative index -1
[10:14:18] [debug] AMX backtrace:
[10:14:18] [debug] #0 0005d890 in public OnPlayerKeyStateChange (0, 16, 0) from lvrp.amx
OnPlayerKeyStateChange code:

Код:
	if(!GetPVarInt(playerid, "spawn")) {
		if(newkeys & KEY_SECONDARY_ATTACK) {
			if(GetPVarInt(playerid, "KaraktertValaszt")) {
				PlayerNamesAcc[playerid] = PlayerNames[playerid];

				new name[24];
				GetPVarString(playerid, "accname", name, sizeof(name));

				if(!strcmp(name, "NULL")) {
					SetPVarInt(playerid, "adatok_0", 0);
					SetPVarInt(playerid, "adatok_1", 0);
					SetPVarInt(playerid, "adatok_2", 0);
					SetPVarInt(playerid, "adatok_3", 0);
					SetPVarInt(playerid, "magassag", 0);
					SetPVarInt(playerid, "testsuly", 0);

					SetPVarInt(playerid, "KaraktertValaszt", 0);
					TextDrawHideForPlayer(playerid, kar[playerid][0]);
					TextDrawHideForPlayer(playerid, kar[playerid][1]);
					TextDrawHideForPlayer(playerid, kar[playerid][2]);

					LoadKarakterTextDraws(playerid);
					SetPVarInt(playerid, "marvanUser", 1);
				}else{
		            PlayerNames[playerid] = name;
					SetPlayerName(playerid, name);

					TextDrawHideForPlayer(playerid, kar[playerid][0]);
					TextDrawHideForPlayer(playerid, kar[playerid][1]);
					TextDrawHideForPlayer(playerid, kar[playerid][2]);
					SetPVarInt(playerid, "KaraktertValaszt", 0);

					LoadPlayer(playerid);
					ClearChat(playerid, 20);

					GetPVarString(playerid, "connectname", name, sizeof(name));
					SendAdminsMessagef("%s elkezdte a jбtйkot '%s' nevű karakterйvel.", name, Name(playerid));

		//			mysql_format(sql, query, sizeof(query), "SELECT * FROM `textdrawok` WHERE Name = '%s'", Name(playerid));
		//			mysql_function_query(sql, query, true, "THREAD_CheckTD", "i", playerid);

					SetTimerEx("FadeOutRegister", 5, false, "ii", playerid, 0);

					SetPVarInt(playerid, "lol", SetTimerEx("StartGame", 1000, true, "i", playerid));
					SetPVarInt(playerid, "spawngame", 0);
				}
			}
		}
	}
HELP pls
Reply
#2

Compile with debug info to get the exact lines: https://github.com/Zeex/samp-plugin-...ith-debug-info

After done with the above procedure, start your server and try to reproduce it or wait for it to occur again - then post your logs again.

I don't see anything wrong that would cause it in OnPlayerKeyStateChange callback so perhaps you posted the code from another script (not lvrp.pwn) or you didn't post the whole code of it?

---

Anyway, the only thing that I noticed and is not related to the problem is:
pawn Код:
PlayerNamesAcc[playerid] = PlayerNames[playerid];
...
PlayerNames[playerid] = name;
If you want to copy strings, the best way to do that is strcpy. Sometimes, direct assignment results in error about size not matching.

pawn Код:
#if !defined strcpy
    #define strcpy(%0,%1) strcat((%0[0] = EOS, %0), %1)
#endif

// native strcpy(destination[], source[], max_length = sizeof destination);
pawn Код:
strcpy(PlayerNamesAcc[playerid], PlayerNames[playerid], 24);
...
strcpy(PlayerNames[playerid], name, 24);
Reply
#3

Thank You Bro!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)