Hey
Kann mir jemand sagen wie ich die nummernschilder in der Datenbank speichern kann?
enum carEnum{
id_x,
carmodel,
besitzer,
Float:c_x,
Float:c_y,
Float:c_z,
Float:c_r,
db_id,
kennzeichen
};
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','%s')",PlayerInfo[playerid][pMySQLID],cInfo[carid][carmodel],cInfo[carid][c_x],cInfo[carid][c_y],cInfo[carid][c_z],cInfo[carid][c_r]);
mysql_query(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][id_x]!=0)continue;
cInfo[i][besitzer]=PlayerInfo[playerid][pMySQLID];
cInfo[i][c_x]=x;
cInfo[i][c_y]=y;
cInfo[i][c_z]=z;
cInfo[i][c_r]=r;
cInfo[i][carmodel]=modelid;
cInfo[i][id_x] = CreateVehicle(modelid,x,y,z,r,-1,-1,-1);
new string[128];
format(string,sizeof(string),"Das Auto cInfo[%i] wurde erstellt.",i);
SetVehicleNumberPlate(cInfo[i][id_x],"LS-000");
SendClientMessageToAll(COLOR_RED,string);
saveCarToDB(playerid,i);
return 1;
}
return 1;
}
public OnPlayerCarsLoad(playerid)
{
new num_rows;
if(!num_rows)return 1;
for(new i=0; i<num_rows; i++)
{
new id=getFreeCarID();
new queryy[256];
format(queryy, sizeof(queryy),"SELECT * FROM `Autos` WHERE `besitzer` = %i",PlayerInfo[playerid][pMySQLID]);
mysql_query(queryy);
cInfo[id][carmodel] = mysql_GetIntByInt("Autos","model","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][besitzer] = mysql_GetIntByInt("Autos","besitzer","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][c_x] = mysql_GetFloatByInt("Autos","x","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][c_y] = mysql_GetFloatByInt("Autos","y","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][c_z] = mysql_GetFloatByInt("Autos","z","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][c_r] = mysql_GetFloatByInt("Autos","r","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][db_id] = mysql_GetIntByInt("Autos","Eintrag","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][kennzeichen] = mysql_GetIntByInt("Autos","kennzeichen","besitzer",PlayerInfo[playerid][pMySQLID]);
cInfo[id][id_x]=CreateVehicle(cInfo[id][carmodel],cInfo[id][c_x],cInfo[id][c_y],cInfo[id][c_z],cInfo[id][c_r],-1,-1,-1);
SetVehicleNumberPlate(cInfo[id][carmodel],cInfo[id][kennzeichen]);
}
return 1;
}
loadPlayerCars(playerid)
{
new query[128];
format(query,sizeof(query),"SELECT * FROM autos WHERE besitzer='%i'",sInfo[playerid][db_id]);
mysql_function_query(dbhandle,query,true,"OnPlayerCarsLoad","i",playerid);
return 1;
}