hello guys i have a save system that works on mysql but it doesnt work well.
When i log out its totally random chance that it gives "[ERROR] CMySQLQuery::Execute[()] - (error #2013) Lost connection to MySQL server during query" error. my save system is onplayerdisconnect and /q commands heres my code:
Код:
public OnPlayerDisconnect(playerid, reason){
q1(playerid);
q2(playerid);
q3(playerid);
manager(INIT, USERDATA, playerid);
return 1;
}
CMD:q(playerid, params[])
{
q1(playerid);
q2(playerid);
q3(playerid);
return 1;
}
forward q1(playerid);
public q1(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Vehicle1",PlayerInfo[playerid][pVehicle1]);
INI_WriteInt(File,"Vehicle1Model",PlayerInfo[playerid][pVehicle1Model]);
INI_WriteFloat(File,"Vehicle1X",PlayerInfo[playerid][pVehicle1X]);
INI_WriteFloat(File,"Vehicle1Y",PlayerInfo[playerid][pVehicle1Y]);
INI_WriteFloat(File,"Vehicle1Z",PlayerInfo[playerid][pVehicle1Z]);
INI_WriteFloat(File,"Vehicle1C",PlayerInfo[playerid][pVehicle1C]);
INI_WriteInt(File,"Vehicle1Color1",PlayerInfo[playerid][pVehicle1Color1]);
INI_WriteInt(File,"Vehicle1Color2",PlayerInfo[playerid][pVehicle1Color2]);
INI_WriteInt(File,"Vehicle1Value",PlayerInfo[playerid][pVehicle1Value]);
INI_WriteInt(File,"Vehicle1Lock",PlayerInfo[playerid][pVehicle1Lock]);
INI_WriteInt(File,"Vehicle1Radio",PlayerInfo[playerid][pVehicle1Radio]);
INI_WriteInt(File,"Vehicle2",PlayerInfo[playerid][pVehicle2]);
INI_WriteInt(File,"Vehicle2Model",PlayerInfo[playerid][pVehicle2Model]);
INI_WriteFloat(File,"Vehicle2X",PlayerInfo[playerid][pVehicle2X]);
INI_WriteFloat(File,"Vehicle2Y",PlayerInfo[playerid][pVehicle2Y]);
INI_WriteFloat(File,"Vehicle2Z",PlayerInfo[playerid][pVehicle2Z]);
INI_WriteFloat(File,"Vehicle2C",PlayerInfo[playerid][pVehicle2C]);
INI_WriteInt(File,"Vehicle2Color1",PlayerInfo[playerid][pVehicle2Color1]);
INI_WriteInt(File,"Vehicle2Color2",PlayerInfo[playerid][pVehicle2Color2]);
INI_WriteInt(File,"Vehicle2Value",PlayerInfo[playerid][pVehicle2Value]);
INI_WriteInt(File,"Vehicle2Lock",PlayerInfo[playerid][pVehicle2Lock]);
INI_WriteInt(File,"Vehicle3",PlayerInfo[playerid][pVehicle3]);
INI_WriteInt(File,"Vehicle2Radio",PlayerInfo[playerid][pVehicle2Radio]);
INI_WriteInt(File,"Vehicle3Model",PlayerInfo[playerid][pVehicle3Model]);
INI_WriteFloat(File,"Vehicle3X",PlayerInfo[playerid][pVehicle3X]);
INI_WriteFloat(File,"Vehicle3Y",PlayerInfo[playerid][pVehicle3Y]);
INI_WriteFloat(File,"Vehicle3Z",PlayerInfo[playerid][pVehicle3Z]);
INI_WriteFloat(File,"Vehicle3C",PlayerInfo[playerid][pVehicle3C]);
INI_WriteInt(File,"Vehicle3Color1",PlayerInfo[playerid][pVehicle3Color1]);
INI_WriteInt(File,"Vehicle3Color2",PlayerInfo[playerid][pVehicle3Color2]);
INI_WriteInt(File,"Vehicle3Value",PlayerInfo[playerid][pVehicle3Value]);
INI_WriteInt(File,"Vehicle3Lock",PlayerInfo[playerid][pVehicle3Lock]);
INI_WriteInt(File,"Vehicle3Radio",PlayerInfo[playerid][pVehicle3Radio]);
INI_Close(File);
return 1;
}
forward q2(playerid);
public q2(playerid)
{
GetPlayerPos(playerid,USER[playerid][POS_X],USER[playerid][POS_Y],USER[playerid][POS_Z]);
GetPlayerFacingAngle(playerid, USER[playerid][ANGLE]);
USER[playerid][MONEY] = GetPlayerMoney(playerid);
new queryb[512];
mysql_format(mysql, queryb, sizeof(queryb), "UPDATE `userlog_info` SET `ADMIN`=%d,`MONEY`=%d,`SKIN`=%d,`POS_X`=%f,`POS_Y`=%f,`POS_Z`=%f, `ANGLE`=%f,`HP`=%f,`AM`=%f, `EXP`=%d, `LEVEL`=%d,`SAVINGS`=%d, `BANK`=%d, `PHONE`=%d, `DONOR`=%d WHERE `ID`=%d",
USER[playerid][ADMIN],
USER[playerid][MONEY],
USER[playerid][SKIN],
USER[playerid][POS_X],
USER[playerid][POS_Y],
USER[playerid][POS_Z],
USER[playerid][ANGLE],
USER[playerid][HP],
USER[playerid][AM],
USER[playerid][EXP],
USER[playerid][LEVEL],
USER[playerid][SAVINGS],
USER[playerid][BANK],
USER[playerid][PHONE],
USER[playerid][DONOR],
USER[playerid][ID]);
mysql_query(mysql, queryb);
return 1;
}
forward q3(playerid);
public q3(playerid)
{
SendClientMessage(playerid,-1,"Your Character Information Has Been Saved.");
DestroyVehicle(personalcar1[playerid]);
DestroyVehicle(personalcar2[playerid]);
DestroyVehicle(personalcar3[playerid]);
return 1;
}