Sonst wurden die Gang Fahrzeuge per File geladen und gespeichert, jetzt wo ich MySQL verwenden möchte, werden Sie nicht gespeichert. Ausgeführt wird SaveGangAutos(); bei /gmx und bei /saveserver. Code:
public LoadGangAutos()
{
new string[128];
mysql_free_result();
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
format(string, sizeof(string),"SELECT * FROM `gangautos` WHERE `SlotID` = '%d'", i);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows() != 0)
{
new val[ 256 ];
mysql_fetch_field("CarID", val); GangAutoInfo[i][cID] = strval( val );
mysql_fetch_field("OwnerID", val); GangAutoInfo[i][cOwner] = strval( val );
mysql_fetch_field("TypID", val); GangAutoInfo[i][cTyp] = strval( val );
mysql_fetch_field("PosX", val); GangAutoInfo[i][cPosX] = floatstr( val );
mysql_fetch_field("PosY", val); GangAutoInfo[i][cPosY] = floatstr( val );
mysql_fetch_field("PosZ", val); GangAutoInfo[i][cPosZ] = floatstr( val );
mysql_fetch_field("Rotation", val); GangAutoInfo[i][cRot] = floatstr( val );
mysql_fetch_field("Farbe1", val); GangAutoInfo[i][cColor1] = strval( val );
mysql_fetch_field("Farbe2", val); GangAutoInfo[i][cColor2] = strval( val );
mysql_fetch_field("Status", val); GangAutoInfo[i][cStatus] = strval( val );
mysql_fetch_field("Tank", val); GangAutoInfo[i][cTank] = strval( val );
mysql_fetch_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();
}
return 1;
}
public SaveGangAutos()
{
new string[128];
for(new i = 0; i < sizeof(GangAutoInfo); i++)
{
format(string, sizeof(string), "SELECT * FROM `gangautos` WHERE `SlotID` = '%d'", i);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows() != 0)
{
format(string, sizeof(string), "INSERT INTO `gangautos` (`SlotID`) VALUES ('%d')", i);
mysql_query(string);
}
mysql_free_result();
new var[256];
format(var, sizeof(var), "UPDATE `gangautos` SET `CarID`='%d', `OwnerID`='%d', `TypID`='%d', `PosX`='%.1f', `PosY`='%.1f', `PosZ`='%.1f', `Rotation`='%.1f', `Farbe1`='%d', `Farbe2`='%d', `Status`='%d', `Tank`='%d', `ReSpawnTime`='%d' WHERE `SlotID`='%d'",
GangAutoInfo[i][cID],
GangAutoInfo[i][cOwner],
GangAutoInfo[i][cTyp],
GangAutoInfo[i][cPosX],
GangAutoInfo[i][cPosY],
GangAutoInfo[i][cPosZ],
GangAutoInfo[i][cRot],
GangAutoInfo[i][cColor1],
GangAutoInfo[i][cColor2],
GangAutoInfo[i][cStatus],
GangAutoInfo[i][cTank],
GangAutoInfo[i][cReSpawnTime],
//GangAutoInfo[i][cStandTime],
i);
mysql_query(var);
}
print("GangAutos Geladen");
return 1;
}
Freue mich über jede hilfe! @Jeffry:
Gruß
Crowley