SA-MP Forums Archive
No save Mysql ? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: No save Mysql ? (/showthread.php?tid=598418)



No save Mysql ? - thaihan - 12.01.2016

My code:
PHP код:
SavePlayer(playerid)
{
    new 
query[3000], date[6], gslot[5], aslot[5], FloathealthFloatarmourstring[20], Float:PosX,    Float:PosY,    Float:PosZ,    Float:PosA;
    
    if(
Logged[playerid])
    {
         
        
GetPlayerPos(playerid,PosX,PosY,PosZ);
        
GetPlayerFacingAngle(playerid,PosA);
        
GetPlayerWeaponData(playerid2gslot[0], aslot[0]);
        
GetPlayerWeaponData(playerid3gslot[1], aslot[1]);
        
GetPlayerWeaponData(playerid4gslot[2], aslot[2]);
        
GetPlayerWeaponData(playerid5gslot[3], aslot[3]);
        
GetPlayerWeaponData(playerid6gslot[4], aslot[4]);
        
getdate(date[0], date[1], date[2]);
        
gettime(date[3], date[4], date[5]);
        
GetPlayerHealth(playeridhealth);
        
GetPlayerArmour(playeridarmour);
        
format(stringsizeof(string), "%d/%d/%d %d:%d:%d"date[0], date[1], date[2], date[3], date[4], date[5]); // last login date
        
//////////////////////////////Thong Tin Co Ban//////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `Admin`=%d, `SkinID`=%d, `AccountLocked`=%d, `AccountBanned`=%d, `BanningAdmin`='%s', `BannedReason`='%s', `Tien`=%d, `TienBank`=%d, `Health`=%f, `Armour`=%f, `LastActivity`='%s' WHERE `ID`=%d",
        
Player[playerid][Admin], GetPlayerSkin(playerid), Player[playerid][AccountLocked], Player[playerid][AccountBanned], Player[playerid][BanningAdmin], Player[playerid][BannedReason], GetPlayerMoney(playerid), Player[playerid][TienBank], healtharmourstringPlayer[playerid][ID]); // Updating the table
////////////////////////////////////Positions///////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `PosX`=%f, `PosY`=%f, `PosZ`=%f, `PosA`=%f WHERE `ID`=%d",\
        
PosXPosYPosZPosAPlayer[playerid][ID]);
////////////////////////////////////Weapons/////////////////////////////////////
        
mysql_format(mysqlquerysizeof(query), "UPDATE `taikhoan` SET `WeaponSlot1`=%d, `WepSlotAmmo1`=%d, `WeaponSlot2`=%d, `WepSlotAmmo2`=%d, `WeaponSlot3`=%d, `WepSlotAmmo3`=%d, `WeaponSlot4`=%d, `WepSlotAmmo4`=%d, `WeaponSlot5`=%d, `WepSlotAmmo5`=%d WHERE `ID`=%d",
        
gslot[0], aslot[0], gslot[1], aslot[1], gslot[2], aslot[2], gslot[3], aslot[3], gslot[4], aslot[4], Player[playerid][ID]); // Updating the table
        
mysql_tquery(mysqlquery""""); // Execute the query
    
}
    return 
1;

Help me.Sorry my bad english.


Re: No save Mysql ? - SaltySandy - 12.01.2016

Any errorlogs? ( server logs & sql logs )


Re: No save Mysql ? - Sk1lleD - 12.01.2016

We need some sql logs, anyway you can try to print the query on server console and then paste it directly into your DBMS, it should give you some error and then it's easier to make it work. This is just my suggestion.


Re: No save Mysql ? - AmigaBlizzard - 12.01.2016

If you have set the "LastActivity" column as "datetime" in MySQL:
PHP код:
    // Get the current date, time
    
getdate(YearMonthDay);
    
gettime(HourMinuteSecond);
    
// Construct the complete date to be added to MySQL for the registration date+time
    
format(Datesizeof(Date), "%04d-%02d-%02d %02d:%02d:%02d"YearMonthDayHourMinuteSecond); 
You need to add the "02" and "04" values to the structure of the date and time.
MySQL expects this structure where all values are 2 characters or 4 characters long.
If you would have the 1st of January, your string would end up like "2016-1-1 0:0:9" for example, when the time is only 9 seconds past midnight, while MySQL expects "2016-01-01 00:00:09".

This won't apply if that column is set a varchar of course, only for datetime.

See if this does the trick.