Guten Abend,
leider kenne ich mich nicht besonderst mit MySQL aus jedoch kann ich sagen das nichts davon richtig funktionieren kann.
Ich habe in der MySQL Datenbank bereits die Struktur erstellt bzw. sie war vorhanden.
C
public LoadGangAutos()
{
if(SaveServerMySQL == 1)
{
new arrCoords[14][64];
new strFromFile2[256];
new File: file = fopen("Configs/cars.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(GangAutoInfo)){
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
GangAutoInfo[idx][cID] = strval(arrCoords[0]);
GangAutoInfo[idx][cOwner] = strval(arrCoords[1]);
GangAutoInfo[idx][cTyp] = strval(arrCoords[2]);
GangAutoInfo[idx][cPosX] = floatstr(arrCoords[3]);
GangAutoInfo[idx][cPosY] = floatstr(arrCoords[4]);
GangAutoInfo[idx][cPosZ] = floatstr(arrCoords[5]);
GangAutoInfo[idx][cRot] = floatstr(arrCoords[6]);
GangAutoInfo[idx][cColor1] = strval(arrCoords[7]);
GangAutoInfo[idx][cColor2] = strval(arrCoords[8]);
GangAutoInfo[idx][cStatus] = strval(arrCoords[9]);
GangAutoInfo[idx][cTank] = strval(arrCoords[10]);
GangAutoInfo[idx][cReSpawnTime] = strval(arrCoords[11]);
GangAutoInfo[idx][cStandTime] = strval(arrCoords[12]);
GangAutoInfo[idx][cMeter] = strval(arrCoords[13]);
if(GangAutoInfo[idx][cStandTime] == 0)
{
GangAutoInfo[idx][cStandTime] = Time();
}
idx++;
}
fclose(file);
}
}
else
{
new string[128];
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
format(string, sizeof(string),"SELECT * FROM `gangautos` WHERE `SlotID` = '%d'", i);
self_mysql_queryEx(string);
mysql_store_result(MySQLConnection);
if(mysql_num_rows(MySQLConnection) != 0)
{
mysql_fetch_row_format(string);
new val[ 256 ];
self_mysql_get_field("CarID", val); GangAutoInfo[i][cID] = strval( val );
self_mysql_get_field("OwnerID", val); GangAutoInfo[i][cOwner] = strval( val );
self_mysql_get_field("TypID", val); GangAutoInfo[i][cTyp] = strval( val );
self_mysql_get_field("PosX", val); GangAutoInfo[i][cPosX] = floatstr( val );
self_mysql_get_field("PosY", val); GangAutoInfo[i][cPosY] = floatstr( val );
self_mysql_get_field("PosZ", val); GangAutoInfo[i][cPosZ] = floatstr( val );
self_mysql_get_field("Rotation", val); GangAutoInfo[i][cRot] = floatstr( val );
self_mysql_get_field("Farbe1", val); GangAutoInfo[i][cColor1] = strval( val );
self_mysql_get_field("Farbe2", val); GangAutoInfo[i][cColor2] = strval( val );
self_mysql_get_field("Status", val); GangAutoInfo[i][cStatus] = strval( val );
self_mysql_get_field("Tank", val); GangAutoInfo[i][cTank] = strval( val );
self_mysql_get_field("ReSpawnTime", val); GangAutoInfo[i][cReSpawnTime] = strval( val );
//self_mysql_get_field("StandTime", val); GangAutoInfo[i][cStandTime] = strval( val );
}
else
{
GangAutoInfo[i][cID] = -1;
GangAutoInfo[i][cOwner] = -1;
GangAutoInfo[i][cTyp] = -1;
GangAutoInfo[i][cPosX] = 0;
GangAutoInfo[i][cPosY] = 0;
GangAutoInfo[i][cPosZ] = 0;
GangAutoInfo[i][cRot] = 0;
GangAutoInfo[i][cColor1] = -1;
GangAutoInfo[i][cColor2] = -1;
GangAutoInfo[i][cStatus] = -1;
GangAutoInfo[i][cTank] = 50;
GangAutoInfo[i][cReSpawnTime] = 1800;
GangAutoInfo[i][cStandTime] = 0;
}
mysql_free_result(MySQLConnection);
if(GangAutoInfo[i][cID] == 65535)
{
GangAutoInfo[i][cID] = -1;
}
}
}
return 1;
}
public SaveGangAutos()
{
new idx;
new File: file2;
idx = 0;
while (idx < sizeof(GangAutoInfo))
{
if(TankSave == 1)
{
if(GangAutoInfo[idx][cID] != -1)
{
GangAutoInfo[idx][cTank] = Gas[GangAutoInfo[idx][cID]];
}
}
new coordsstring[128];
format(coordsstring, sizeof(coordsstring), "%d|%d|%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d\n",
GangAutoInfo[idx][cID],
GangAutoInfo[idx][cOwner],
GangAutoInfo[idx][cTyp],
GangAutoInfo[idx][cPosX],
GangAutoInfo[idx][cPosY],
GangAutoInfo[idx][cPosZ],
GangAutoInfo[idx][cRot],
GangAutoInfo[idx][cColor1],
GangAutoInfo[idx][cColor2],
GangAutoInfo[idx][cStatus],
GangAutoInfo[idx][cTank],
GangAutoInfo[idx][cReSpawnTime],
GangAutoInfo[idx][cStandTime],
GangAutoInfo[idx][cMeter]);
if(idx == 0)
{
file2 = fopen("Configs/cars.cfg", io_write);
}
else
{
file2 = fopen("Configs/cars.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
print("GangAutos Geladen");
}
Alles anzeigen
Könnte mir jemand behilflich sein die beiden Publics umzuändern ?
Gern auch mit Gegenleistung.
Mit freundlichen Grüßen