Guten Tag Breadfish,
mein System basiert auf MySQL R39-3!
Das Problem ist wenn 2 Fahrzeuge für einen Spieler oder mehr sind laden die Fahrzeuge garnicht.
enum carEnum{
cid_x,
c_model,
c_besitzer,
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
cc_1,
cc_2,
cdb_id,
c_kennzeichen[14]
}
new cInfo[50][carEnum];
public carSavedToDB(carid)
{
cInfo[carid][cdb_id]=cache_insert_id(dbhandle);
printf("carSavedToDB(%i)", cache_insert_id(dbhandle));
return 1;
}
saveCarToDB(playerid,carid)
{
new query[2048];
format(query,sizeof(query),"INSERT INTO pcars (BesitzerID,Model,X,Y,Z,R,Kennzeichen) VALUES ('%i','%i','%f','%f','%f','%f','%s')",pInfo[playerid][db_id],cInfo[carid][c_model],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r],cInfo[carid][c_kennzeichen]);
mysql_function_query(dbhandle,query,true,"carSavedToDB","i",carid);
printf("Fahrzeug: %s", query);
return 1;
}
createPlayerCar(playerid,modelid,Float:x,Float:y,Float:z,Float:r)
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][cid_x]!=0)continue;
cInfo[i][c_besitzer]=pInfo[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][c_model]=modelid;
cInfo[i][cc_1] = 1;
cInfo[i][cc_2] = 1;
cInfo[i][cid_x] = CreateVehicle(modelid,x,y,z,r,1,1,-1);
new lsc_kennzeichen[14],thename[3];
format(thename,3,"%s",pName(playerid));
format(lsc_kennzeichen,sizeof(lsc_kennzeichen),"SA-%s-%i",thename,1000+random(8999));
cInfo[i][c_kennzeichen] = lsc_kennzeichen;
SetVehicleNumberPlate(cInfo[i][cid_x], lsc_kennzeichen);
SetVehicleToRespawn(cInfo[i][cid_x]);
saveCarToDB(playerid,i);
printf("Test createplayercar: %s", saveCarToDB(playerid, cInfo[i][cid_x]));
return 1;
}
return 1;
}
getFreeCarID()
{
for(new i=0; i<sizeof(cInfo); i++)
{
if(cInfo[i][cid_x]==0)return i;
}
return 0;
}
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();
new ccnplate[12];
cInfo[id][c_model]=cache_get_field_content_int(i,"Model",dbhandle);
cInfo[id][c_besitzer]=cache_get_field_content_int(i,"BesitzerID",dbhandle);
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][cdb_id]=cache_get_field_content_int(i,"id",dbhandle);
cInfo[id][cc_1] = cache_get_field_content_int(i, "Farbe1",dbhandle);
cInfo[id][cc_2] = cache_get_field_content_int(i, "Farbe2",dbhandle);
cache_get_field_content(i, "Kennzeichen", ccnplate, dbhandle, 12);
strmid(cInfo[id][c_kennzeichen], ccnplate, 0, 12, 12);
cInfo[id][cid_x]=CreateVehicle(cInfo[id][c_model],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],cInfo[id][cc_1],cInfo[id][cc_2], -1);
SetVehicleNumberPlate(cInfo[id][cid_x], cInfo[id][c_kennzeichen]);
SetVehicleToRespawn(cInfo[id][cid_x]);
SetPVarInt(playerid, "NeonStatus", cache_get_field_content_int(i, "NeonStatus",dbhandle));
if(GetPVarInt(playerid, "NeonStatus") == 1)//Rot
{
SetPVarInt(playerid, "NeonStatus", 1);
SetPVarInt(playerid, "NeonRot1", CreateObject(18647,0,0,0,0,0,0));
SetPVarInt(playerid, "NeonRot2", CreateObject(18647,0,0,0,0,0,0));
AttachObjectToVehicle(GetPVarInt(playerid, "NeonRot1"), cInfo[id][cid_x], -0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
AttachObjectToVehicle(GetPVarInt(playerid, "NeonRot2"), cInfo[id][cid_x], 0.8, 0.0, -0.70, 0.0, 0.0, 0.0);
}
return 99999;
}
return 1;
}
loadPlayerCars(playerid)
{
new query[458];
format(query,sizeof(query),"SELECT * FROM pcars WHERE BesitzerID='%i'",pInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
return 1;
}
Ich bitte um hilfe!
Lg,
Skoam