Guten Tag.
Mir ist jetzt mein Befehl um Fahrzeuge zu parken
Enum:
enum autoEnum{
id_x,
model,
besitzer[MAX_PLAYER_NAME],
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
db_id
}
new aInfo[50][autoEnum];
Befehl um die Fahrzeuge zu parken:
ocmd:autoparken(playerid, params[])
{
new vID = GetPlayerVehicleID(playerid);
if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, hellgrün, "Du bist in kein Auto!");
for (new i = 0; i < sizeof(aInfo); i++)
{
if(vID == aInfo[i] [autoEnum])
{
if(!strcmp(aInfo[i][besitzer], SpielerName(playerid)))
{
new query[128];
GetVehiclePos(vID, aInfo[i][c_x],aInfo[i][c_y],aInfo[i][c_z]);
GetVehicleZAngle(vID,aInfo[i][c_r]);
format(query, sizeof(query), "UPDATE Autos SET c_x='%f',c_y='%f',c_z='%f',c_r='%f' WHERE id='%i' ",aInfo[i] [c_x],aInfo[i] [c_y],aInfo[i] [c_z],aInfo[i] [c_r],aInfo[i] [db_id]);
mysql_function_query(dbhandle,query,false," "," ");
SendClientMessage(playerid, hellgrün, "Du hast dein Auto geparkt.");
return 1;
}
break;
}
}
return SendClientMessage(playerid, hellgrün, "Du sitzt nicht in deinem Auto!");
}
Fehler:
samplernen.p(895) : error 032: array index out of bounds (variable "aInfo")
samplernen.p(943) : error 032: array index out of bounds (variable "aInfo")
samplernen.p(951) : error 032: array index out of bounds (variable "aInfo")
Es hängt aber auch noch mit:
createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
{
for(new i=0; i<sizeof(aInfo); i++)
{
if(aInfo[i][id_x]!=0)continue;
aInfo[i][besitzer]=sInfo[playerid][db_id];
aInfo[i][c_x] =x;
aInfo[i][c_y] =y;
aInfo[i][c_z] =z;
aInfo[i][c_r] =r;
aInfo[i][model] =modelid;
aInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,-1,-1,-1);
new string[128];
format(string,sizeof(string),"Das Auto aInfo[%i]wurde erstellt",i);
SendClientMessageToAll(duneklhelblau,string);
saveCarToDB(playerid,i);
return 1;
}
return 1;
}
in verbindung also wird es glaub ich schwer die sache zu beheben
public carSavedToDB(carid)
{
aInfo[carid][db_id]=cache_insert_id(dbhandle);
return 1;
}
saveCarToDB(playerid,carid)
{
new query[128];
format(query,sizeof(query),"INSERT INTO autos(besitzer,model,x,y,z,r) VALUES('%i','%i','%f','%f','%f','%f')",sInfo[playerid][db_id],aInfo[carid][model],aInfo[carid][c_x],aInfo[carid][c_y],aInfo[carid][c_z],aInfo[carid][c_r]);
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
return 1;
}