mrrares19 Posted February 2, 2023 Posted February 2, 2023 [debug] Run time error 4: "Array index out of bounds" [debug] Attempted to read/write array element at index 101 in array of size 101 [debug] AMX backtrace: [debug] #0 00344398 in public DecreaseTimer () at mrx.pwn:30372 30372: foreach(PersonalVSpawned, idd) if(CarInfo[idd][cTime] < gettime() && CarInfo[idd][cTime] != -1) DestroyPlayerCar(idd); stock-ul in caz ca e nevoie: stock DestroyPlayerCar(dbid) { if(CarInfo[dbid][Spawned] == 0) return true; VehicleOwned[CarInfo[dbid][Spawned]] = 0; VehicleSQL[CarInfo[dbid][Spawned]] = 0; CarInfo[dbid][cTime] = -1; new Float: Pos[3]; GetVehiclePos(CarInfo[dbid][Spawned], Pos[0], Pos[1], Pos[2]); if(strlen(CarInfo[dbid][cText]) >= 3) DestroyDynamicObject(nameobject[CarInfo[dbid][Spawned]]); if(CarInfo[dbid][cNeon]) { DestroyDynamicObject(NeonObj[0][CarInfo[dbid][Spawned]]); DestroyDynamicObject(NeonObj[1][CarInfo[dbid][Spawned]]); } Iter_Remove(PersonalVSpawned, dbid); MyVehicleSpawn[CarInfo[dbid][cOnline]] --; CarInfo[dbid][cFuel] = Gas[CarInfo[dbid][Spawned]]; mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `cars` SET `Fuel`='%d' WHERE `ID`='%d'", CarInfo[dbid][cFuel], CarInfo[dbid][cID]); mysql_tquery(SQL, gQuery, "", ""); CarInfo[dbid][cLastPos][0] = Pos[0]; CarInfo[dbid][cLastPos][1] = Pos[1]; CarInfo[dbid][cLastPos][2] = Pos[2]; DestroyVehicle(CarInfo[dbid][Spawned]); CarInfo[dbid][Spawned] = 0; return true; } Va rog ajutati-ma ,nu scap de eroarea asta de 1 luna !
0 R X S Posted March 12, 2023 Posted March 12, 2023 (edited) foreach(PersonalVSpawned, idd) { if(idd < sizeof(CarInfo) && CarInfo[idd][cTime] < gettime() && CarInfo[idd][cTime] != -1) { DestroyPlayerCar(idd); } } Poftiti domnu’. Verificăm mai întâi dacă idd este mai mic decât dimensiunea array-ului CarInfo și accesam elementul numai dacă este valid. sau foreach(PersonalVSpawned, idd) { if(idd >= 0 && idd < 101 && CarInfo[idd][cTime] < gettime() && CarInfo[idd][cTime] != -1) { DestroyPlayerCar(idd); } } Aici verificăm dacă indicele idd este între 0 și 100 (101 elemente în total), iar dacă este, verificăm și dacă poziția respectivă a matricei CarInfo a fost alocată. Greu cu indentarea pentru că-s pe telefon. Problema actuala are multe fețe, atât de percepere cât si de rezolvare. Nu am mai scriptat de peste 5 ani așadar sper că ce spun e corect si valid pentru soluția ta. Încearcă ce ți am dat, o ducem la capăt oricum. Edited March 12, 2023 by R X S
0 mrrares19 Posted August 24, 2023 Author Posted August 24, 2023 pentru ce-i ce nu au rezolvat stock-ul : stock DestroyPlayerCar(dbid, bool:useinloop = false) { if(CarInfo[dbid][Spawned] == 0) return true; VehicleOwned[CarInfo[dbid][Spawned]] = 0; VehicleSQL[CarInfo[dbid][Spawned]] = 0; CarInfo[dbid][cTime] = -1; gQuery[0] = EOS; new Float: Pos[3]; GetVehiclePos(CarInfo[dbid][Spawned], Pos[0], Pos[1], Pos[2]); if(strlen(CarInfo[dbid][cText]) >= 3) DestroyDynamicObject(nameobject[CarInfo[dbid][Spawned]]); if(CarInfo[dbid][cNeon]) for(new i = 0; i < 2; i++) DestroyDynamicObject(NeonObj[i][CarInfo[dbid][Spawned]]); if(!useinloop) Iter_Remove(PersonalVSpawned, dbid); MyVehicleSpawn[CarInfo[dbid][cOnline]] --; CarInfo[dbid][cFuel] = Gas[CarInfo[dbid][Spawned]]; mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `cars` SET `Fuel`='%d' WHERE `ID`='%d'", CarInfo[dbid][cFuel], CarInfo[dbid][cID]); mysql_tquery(SQL, gQuery, "", ""); for(new i = 0; i < 3; i++) CarInfo[dbid][cLastPos][i] = Pos[i]; DestroyVehicle(CarInfo[dbid][Spawned]); CarInfo[dbid][Spawned] = 0; saveCar(dbid); mysql_format(SQL, gQuery, sizeof gQuery , "UPDATE cars SET Spawned='%d' WHERE ID=%d", CarInfo[dbid][Spawned], CarInfo[dbid][cID]); mysql_tquery(SQL, gQuery, "", ""); return true; } linia din decreasetimer: foreach(new idd: PersonalVSpawned) { if(CarInfo[idd][cTime] < gettime() && CarInfo[idd][cTime] != -1) { DestroyPlayerCar(idd, true); Iter_Remove(PersonalVSpawned, idd); } }
0 Sancky Posted August 24, 2023 Posted August 24, 2023 Iter_SafeRemove e solutia frt pt versiuni mai vechi de YSI
0 mrrares19 Posted August 24, 2023 Author Posted August 24, 2023 (edited) 2 hours ago, Sancky said: Iter_SafeRemove e solutia frt pt versiuni mai vechi de YSI lucrez pe ultima versiune nu mai este recomandat sa folosesti iter_SafeRemove, + cand eram pe ysi 3 , tot nu a mers cu saferemove, mna burned ce sa ceri bug-uri peste bug-uri Edited August 24, 2023 by mrrares19
0 Sancky Posted August 24, 2023 Posted August 24, 2023 1 hour ago, mrrares19 said: lucrez pe ultima versiune nu mai este recomandat sa folosesti iter_SafeRemove, + cand eram pe ysi 3 , tot nu a mers cu saferemove, mna burned ce sa ceri bug-uri peste bug-uri n ai stiut sa l folosesti cum trb. 1
0 mrrares19 Posted August 25, 2023 Author Posted August 25, 2023 probabil, dar tin minte ca metoda asta mi au aratat-o baieti de la open mp
Question
mrrares19
[debug] Run time error 4: "Array index out of bounds"
[debug] Attempted to read/write array element at index 101 in array of size 101
[debug] AMX backtrace:
[debug] #0 00344398 in public DecreaseTimer () at mrx.pwn:30372
30372: foreach(PersonalVSpawned, idd) if(CarInfo[idd][cTime] < gettime() && CarInfo[idd][cTime] != -1) DestroyPlayerCar(idd);
stock-ul in caz ca e nevoie:
stock DestroyPlayerCar(dbid) {
if(CarInfo[dbid][Spawned] == 0) return true;
VehicleOwned[CarInfo[dbid][Spawned]] = 0;
VehicleSQL[CarInfo[dbid][Spawned]] = 0;
CarInfo[dbid][cTime] = -1;
new Float: Pos[3];
GetVehiclePos(CarInfo[dbid][Spawned], Pos[0], Pos[1], Pos[2]);
if(strlen(CarInfo[dbid][cText]) >= 3) DestroyDynamicObject(nameobject[CarInfo[dbid][Spawned]]);
if(CarInfo[dbid][cNeon]) {
DestroyDynamicObject(NeonObj[0][CarInfo[dbid][Spawned]]);
DestroyDynamicObject(NeonObj[1][CarInfo[dbid][Spawned]]);
}
Iter_Remove(PersonalVSpawned, dbid);
MyVehicleSpawn[CarInfo[dbid][cOnline]] --;
CarInfo[dbid][cFuel] = Gas[CarInfo[dbid][Spawned]];
mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `cars` SET `Fuel`='%d' WHERE `ID`='%d'", CarInfo[dbid][cFuel], CarInfo[dbid][cID]);
mysql_tquery(SQL, gQuery, "", "");
CarInfo[dbid][cLastPos][0] = Pos[0];
CarInfo[dbid][cLastPos][1] = Pos[1];
CarInfo[dbid][cLastPos][2] = Pos[2];
DestroyVehicle(CarInfo[dbid][Spawned]);
CarInfo[dbid][Spawned] = 0;
return true;
}
Va rog ajutati-ma ,nu scap de eroarea asta de 1 luna !
6 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now