Hi,
bekomme Errors in der Log, wenn ich den Server starte:
[17:03:10] [debug] Run time error 4: "Array index out of bounds"
[17:03:10] [debug] Accessing element at index 65535 past array upper bound 1999
[17:03:10] [debug] AMX backtrace:
[17:03:10] [debug] #0 000b78b0 in public CreateGangAutos () at C:\Users\Nick\Desktop\LiP\gamemodes\LiPR.pwn:15878
[17:03:10] [debug] #1 0010dd70 in public OnGameModeInit () at C:\Users\Nick\Desktop\LiP\gamemodes\LiPR.pwn:19760
Zeile 15878:
Code
public CreateGangAutos()
{
printf("CreateGangAutos");
for(new h = 0; h < sizeof(GangAutoInfo); h++){
printf("sizeof(gangautoinfo)");
if(GangAutoInfo[h][cTyp] != -1){
printf("GangAutoInfo CTYP != -1");
if(GangAutoInfo[h][cStatus] == 0){
printf("GangAutoInfo Status == 0");
if(GangAutoInfo[h][cID] == INVALID_VEHICLE_ID) return printf("INVALID_VEHICLE_ID"); //Keine Ahnung, warum er nicht returnt...
GangAutoInfo[h][cID] = CreateVehicle(GangAutoInfo[h][cTyp],GangAutoInfo[h][cPosX],GangAutoInfo[h][cPosY],GangAutoInfo[h][cPosZ],GangAutoInfo[h][cRot],GangAutoInfo[h][cColor1],GangAutoInfo[h][cColor2],GangAutoInfo[h][cReSpawnTime]);
printf("CreateVehicle");
printf("cID = %d", GangAutoInfo[h][cID]); //Printet 65535
printf("Tank = %d", GangAutoInfo[h][cTank]); // -> 0
printf("Gas = %d",Gas[GangAutoInfo[h][cID]] );//Printet nicht.
Gas[GangAutoInfo[h][cID]] = GangAutoInfo[h][cTank]; //< ERROR Zeile 15878>
printf("GAS = %d || CreateVehicle = %d",Gas[GangAutoInfo[h][cID]],GangAutoInfo[h][cID]);
new string[50];
format(string, sizeof(string), "{FFFF00}LiR-{21DD00}%d", GangAutoInfo[h][cID]);
SetVehicleNumberPlate(GangAutoInfo[h][cID],string);
if(IsAWheelmanCar(h))
{
SetVehicleHealth(h, 2000);
}
}}}
return 1;
}
Alles anzeigen
Nach printf("Tank = %d", GangAutoInfo[h][cTank]); gehts nicht mehr weiter.
Zeile 19760:
public OnGameModeInit()
{
CreateGangAutos();
[...]
}
Gas :
new Gas[MAX_VEHICLES];
GangAutoInfo:
Code
#define MaxGangAutos 750
enum GAInfo
{
cID,
cOwner,
cTyp,
Float:cPosX,
Float:cPosY,
Float:cPosZ,
Float:cRot,
cColor1,
cColor2,
cStatus,
cTank,
cReSpawnTime,
cStandTime,
cMeter,
};
new GangAutoInfo[MaxGangAutos][GAInfo];
Alles anzeigen
LoadGangAutos:
OnGameModeInIt:
Code
mysql_format(handle, string2, sizeof(string2), "SELECT * FROM `gangautos`");
mysql_pquery(handle, string2, "LoadGangAutos", "");
Irgendwo unten im Script:
Code
public LoadGangAutos()
{
new rows = cache_get_row_count();
for(new i, j = rows; i < j ; i++)
{
if(rows != 0)
{
GangAutoInfo[i][cID] = cache_get_field_content_int(i, "CarID");
GangAutoInfo[i][cOwner] = cache_get_field_content_int(i, "OwnerID");
GangAutoInfo[i][cTyp] = cache_get_field_content_int(i, "TypID");
GangAutoInfo[i][cPosX] = cache_get_field_content_int(i, "PosX");
GangAutoInfo[i][cPosY] = cache_get_field_content_int(i, "PosY");
GangAutoInfo[i][cPosZ] = cache_get_field_content_int(i, "PosZ");
GangAutoInfo[i][cRot] = cache_get_field_content_int(i, "Rotation");
GangAutoInfo[i][cColor1] = cache_get_field_content_int(i, "Farbe1");
GangAutoInfo[i][cColor2] = cache_get_field_content_int(i, "Farbe2");
GangAutoInfo[i][cStatus] = cache_get_field_content_int(i, "Status");
GangAutoInfo[i][cTank] = cache_get_field_content_int(i, "Tank");
GangAutoInfo[i][cReSpawnTime] = cache_get_field_content_int(i, "ReSpawnTime");
GangAutoInfo[i][cStandTime] = cache_get_field_content_int(i, "StandTime");
}
else
{
GangAutoInfo[i][cID] = -1;
GangAutoInfo[i][cOwner] = -1;
GangAutoInfo[i][cTyp] = -1;
GangAutoInfo[i][cPosX] = 0;
GangAutoInfo[i][cPosY] = 0;
GangAutoInfo[i][cPosZ] = 0;
GangAutoInfo[i][cRot] = 0;
GangAutoInfo[i][cColor1] = -1;
GangAutoInfo[i][cColor2] = -1;
GangAutoInfo[i][cStatus] = -1;
GangAutoInfo[i][cTank] = 50;
GangAutoInfo[i][cReSpawnTime] = 1800;
}
if(GangAutoInfo[i][cStandTime] == 0)
{
GangAutoInfo[i][cStandTime] = Time();
}
if(GangAutoInfo[i][cID] == 65535)
{
GangAutoInfo[i][cID] = -1;
}
printf("cID = %d", GangAutoInfo[i][cID]); // Printet die richtigen ID's
}
return 1;
}
Alles anzeigen
SaveGangAutos:
Code
public SaveGangAutos()
{
new string[500];
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
if(TankSave == 1)
{
if(GangAutoInfo[i][cID] != -1)
{
GangAutoInfo[i][cTank] = Gas[GangAutoInfo[i][cID]];
}
}
mysql_format(handle,string, sizeof(string), "UPDATE `gangautos` SET `CarID`='%d', `OwnerID`='%d', `TypID`='%d', `PosX`='%.1f', `PosY`='%.1f', `PosZ`='%.1f', `Rotation`='%.1f', `Farbe1`='%d', `Farbe2`='%d', `Status`='%d', `Tank`='%d', `ReSpawnTime`='%d', `StandTime`='%d' WHERE `SlotID`='%d'",
GangAutoInfo[i][cID],GangAutoInfo[i][cOwner],GangAutoInfo[i][cTyp],GangAutoInfo[i][cPosX],GangAutoInfo[i][cPosY],GangAutoInfo[i][cPosZ],GangAutoInfo[i][cRot],GangAutoInfo[i][cColor1], GangAutoInfo[i][cColor2],GangAutoInfo[i][cStatus],GangAutoInfo[i][cTank],GangAutoInfo[i][cReSpawnTime],
GangAutoInfo[i][cStandTime],i);
mysql_pquery(handle, string);
}
print("GangAutos Geladen");
return 1;
}
Alles anzeigen
Hoffe ihr könnt mir helfen.
Danke!