Ich stehe nach meinem Umdenken sowie Umbau immer mal wieder vor diesem einem Problem.
Ich habe das Fahrzeug System unter ein Array verallgemeinert, egal ob es sich um das CopCar System dreht oder um das GlobalCar System.. irgendein Fahrzeug aus der Kette spawnt nicht, das gilt für beide Systeme.
Ich nutze als Index (der Wert in der Mitte) die VehicleID selbst, ich finde so spare unnötig viele Schleifen.
Quellcode:
enum E_VEHICLE
{
//Int werde
vSQL,
vVehicle,
vType,
vModel,
vColor1,
vColor2,
vRDelay,
vSiren,
vSkill,
//Float werte
Float:vTankvol,
Float:vX,
Float:vY,
Float:vZ,
Float:vR,
//boolean werte
bool:vTanktive,
vEngine,
};
enum
{
VTYPE_COP,
VTYPE_ADMIN,
VTYPE_GLOBAL,
};
public QueryFinish(QUERY)
{
switch(QUERY)
{
case QUERY_LOADCOPVEH:
{
for(new i, cachedVehicle, cachedVehSQL, cachedModel, cachedSkill, Float:chX, Float:chY, Float:chZ, Float:chR;i<rows;i++)
{
if(Vehicle[i][vVehicle])continue;
cache_get_value_name_int(i, "id", cachedVehSQL),
cache_get_value_name_int(i, "Model", cachedModel),
cache_get_value_name_int(i, "Skill", cachedSkill),
cache_get_value_name_float(i, "X", chX),
cache_get_value_name_float(i, "Y", chY),
cache_get_value_name_float(i, "Z", chZ),
cache_get_value_name_float(i, "R", chR),
cachedVehicle = CreateVehicleEx(cachedModel, chX, chY, chZ, chR, -1, -1, -1, 1);
Vehicle[cachedVehicle][vVehicle] = cachedVehicle,
Vehicle[cachedVehicle][vSQL] = cachedVehSQL,
Vehicle[cachedVehicle][vModel]= cachedModel,
Vehicle[cachedVehicle][vSkill] = cachedSkill,
Vehicle[cachedVehicle][vX] = chX,
Vehicle[cachedVehicle][vY] = chY,
Vehicle[cachedVehicle][vZ] = chZ,
Vehicle[cachedVehicle][vR] = chR,
Vehicle[cachedVehicle][vType] = VTYPE_COP,
Vehicle[cachedVehicle][vTankvol] = 100.0,
Vehicle[cachedVehicle][vTanktive] = true,
printf("LOADCV: Type: %d, SQL: %d, Model: %d, Skill: %d, Pos: %f,%f,%f,%f, IVehID: %d", Vehicle[cachedVehicle][vType], cachedVehSQL, cachedModel, cachedSkill, chX, chY, chZ, chR, cachedVehicle);
}
}
case QUERY_LOADGLOBALVEH:
{
for(new i, cachedVehicle, cachedVehSQL, cachedModel, cachedColOne, cachedColSecond, Float:chX, Float:chY, Float:chZ, Float:chR;i<rows;i++)
{
if(Vehicle[i][vVehicle])continue;
cache_get_value_name_int(i, "DatabaseID", cachedVehSQL),
cache_get_value_name_int(i, "Model", cachedModel),
cache_get_value_name_int(i, "Color1", cachedColOne),
cache_get_value_name_int(i, "Color2", cachedColSecond),
cache_get_value_name_float(i, "X", chX),
cache_get_value_name_float(i, "Y", chY),
cache_get_value_name_float(i, "Z", chZ),
cache_get_value_name_float(i, "R", chR),
cachedVehicle = CreateVehicleEx(cachedModel, chX, chY, chZ, chR, cachedColOne, cachedColSecond, -1, 0);
Vehicle[cachedVehicle][vVehicle] = cachedVehicle,
Vehicle[cachedVehicle][vSQL] = cachedVehSQL,
Vehicle[cachedVehicle][vModel]= cachedModel,
Vehicle[cachedVehicle][vX] = chX,
Vehicle[cachedVehicle][vY] = chY,
Vehicle[cachedVehicle][vZ] = chZ,
Vehicle[cachedVehicle][vR] = chR,
Vehicle[cachedVehicle][vColor1] = cachedColOne,
Vehicle[cachedVehicle][vColor2] = cachedColSecond,
Vehicle[cachedVehicle][vType] = VTYPE_GLOBAL,
Vehicle[cachedVehicle][vTankvol] = 100.0,
Vehicle[cachedVehicle][vTanktive] = true;
printf("LOADGLOBALCAR: Type: %d, SQL: %d, Model: %d, Pos: %f,%f,%f,%f, IVehID: %d", Vehicle[cachedVehicle][vType], cachedVehSQL, cachedModel, chX, chY, chZ, chR, cachedVehicle);
}
}
}
}