08.04.2017, 01:48
Hello friends i have a mysql and y_ini save system for my server but when people do /q or leave normally server cant process my code. my code doesnt have a problem tho same code exists under /saveme command and it works perfectly. Only i cant manage to save on disconnect. I am open to any suggestion
Heres my code:
Heres my code:
Код:
CMD:q(playerid, params[]) { if(!INGAME[playerid][LOGIN]) return SendClientMessage(playerid,-1,"not login"); 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); 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 query[256]; mysql_format(mysql, query, sizeof(query), "UPDATE `userlog_info` SET `ADMIN`=%d,`MONEY`=%d,`KILLS`=%d,`DEATHS`=%d,`SKIN`=%d,`POS_X`=%f,`POS_Y`=%f,`POS_Z`=%f WHERE `ID`=%d", USER[playerid][ADMIN], USER[playerid][MONEY], USER[playerid][KILLS], USER[playerid][DEATHS], USER[playerid][SKIN], USER[playerid][POS_X], USER[playerid][POS_Y], USER[playerid][POS_Z], USER[playerid][ID]); mysql_query(mysql, query); mysql_format(mysql, query, sizeof(query), "UPDATE `userlog_info` SET `ANGLE`=%f,`HP`=%f,`AM`=%f, `EXP`=%d, `LEVEL`=%d,`SAVINGS`=%d, `BANK`=%d, `PHONE`=%d, `DONOR`=%d WHERE `ID`=%d", 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, query); SendClientMessage(playerid,-1,"Your Character Information Has Been Saved."); DestroyVehicle(personalcar1[playerid]); DestroyVehicle(personalcar2[playerid]); DestroyVehicle(personalcar3[playerid]); return 1; } public OnPlayerDisconnect(playerid) { if(!INGAME[playerid][LOGIN]) return SendClientMessage(playerid,-1,"not login"); 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); 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 query[256]; mysql_format(mysql, query, sizeof(query), "UPDATE `userlog_info` SET `ADMIN`=%d,`MONEY`=%d,`KILLS`=%d,`DEATHS`=%d,`SKIN`=%d,`POS_X`=%f,`POS_Y`=%f,`POS_Z`=%f WHERE `ID`=%d", USER[playerid][ADMIN], USER[playerid][MONEY], USER[playerid][KILLS], USER[playerid][DEATHS], USER[playerid][SKIN], USER[playerid][POS_X], USER[playerid][POS_Y], USER[playerid][POS_Z], USER[playerid][ID]); mysql_query(mysql, query); mysql_format(mysql, query, sizeof(query), "UPDATE `userlog_info` SET `ANGLE`=%f,`HP`=%f,`AM`=%f, `EXP`=%d, `LEVEL`=%d,`SAVINGS`=%d, `BANK`=%d, `PHONE`=%d, `DONOR`=%d WHERE `ID`=%d", 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, query); SendClientMessage(playerid,-1,"Your Character Information Has Been Saved."); DestroyVehicle(personalcar1[playerid]); DestroyVehicle(personalcar2[playerid]); DestroyVehicle(personalcar3[playerid]); return 1; }