Das ist die Funktion in der das Auto erstellt wird:
createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][id_x]!=0)continue;
new name[24];GetPlayerName(playerid,name,24);
format(cInfo[i][besitzer_name],24,"%s",name);
cInfo[i][besitzer]=sInfo[playerid][db_id];
cInfo[i][c_x]=x;
cInfo[i][c_y]=y;
cInfo[i][c_z]=z;
cInfo[i][c_r]=r;
cInfo[i][model]=modelid;
cInfo[i][farbe1]=farbe1;
cInfo[i][farbe2]=farbe2;
cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,farbe1,farbe2,-1);
CarTank[cInfo[i][id_x]]=MaxTank[modelid-400];
SetVehicleNumberPlate(cInfo[i][id_x],cInfo[i][besitzer_name]);
SetVehicleToRespawn(cInfo[i][id_x]);
saveCarToDB(playerid,i);
return 1;
}
return 1;
}
Und wenn es mal erstellt wurde lädt er es hier raus:
public OnPlayerCarsLoad(playerid)
{
new num_fields,num_rows;
cache_get_data(num_rows,num_fields,dbhandle);
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
new id=getFreeCarID(),zname[24];
cInfo[id][model]=cache_get_field_content_int(i,"model",dbhandle);
cInfo[id][besitzer]=cache_get_field_content_int(i,"besitzer",dbhandle);
cache_get_field_content(i,"besitzer_name",zname,dbhandle);
format(cInfo[id][besitzer_name],24,"%s",zname);
cInfo[id][c_x]=cache_get_field_content_float(i,"x",dbhandle);
cInfo[id][c_y]=cache_get_field_content_float(i,"y",dbhandle);
cInfo[id][c_z]=cache_get_field_content_float(i,"z",dbhandle);
cInfo[id][c_r]=cache_get_field_content_float(i,"r",dbhandle);
cInfo[id][farbe1]=cache_get_field_content_int(i,"farbe1",dbhandle);
cInfo[id][farbe2]=cache_get_field_content_int(i,"farbe2",dbhandle);
cInfo[id][abgeschleppt]=!!cache_get_field_content_int(i,"abgeschleppt",dbhandle);
cInfo[id][db_id]=cache_get_field_content_int(i,"id",dbhandle); //suchehier
cInfo[id][id_x]=CreateVehicle(cInfo[id][model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][farbe1],cInfo[id][farbe2],-1);
printf("%s",cInfo[id][besitzer_name]);
SetVehicleNumberPlate(cInfo[id][id_x],cInfo[id][besitzer_name]);
SetVehicleToRespawn(cInfo[id][id_x]);
CarTank[cInfo[id][id_x]]=cache_get_field_content_int(i, "tank", dbhandle);
}
return 1;
}