mysql query (small doubt)
#9

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Try to make the MySQL Database on the same address as the server, it reduces the time taken to execute it, and just update the data you wanna update, once it changes, instead of making huge queries
I have a big doubt in this section tho

pawn Код:
stock SavePlayerData(playerid)
{
    if(PlayerInfo[playerid][pLoggedIn] == 1)

        new year,month,day;
        getdate(year, month, day);
        new Float:x,Float:y,Float:z, interior;
        GetPlayerPos(playerid,x,y,z);   interior = GetPlayerInterior(playerid);
        new query[1600], pname[24];
        GetPlayerName(playerid, pname, 24);

        mysql_format(mysql, query, sizeof(query), "UPDATE players SET TP=%d, Function1=%d, Function2=%d, Function3=%d, Function4=%d, Function5=%d, Function6=%d, Bank=%d, weed=%d, Condoms=%d, inalcatraz=%d, hours=%d, minutes=%d, seconds=%d WHERE user='%e'",
        PlayerInfo[playerid][TP],PlayerInfo[playerid][Function1],PlayerInfo[playerid][Function2],PlayerInfo[playerid][Function3],PlayerInfo[playerid][Function4],PlayerInfo[playerid][Function5],PlayerInfo[playerid][Function6],PlayerInfo[playerid][bank],PlayerInfo[playerid][weed],PlayerInfo[playerid][condoms],PlayerInfo[playerid][inalcatraz],PlayerInfo[playerid][pHour],PlayerInfo[playerid][pMin],PlayerInfo[playerid][pSec],pname);
        mysql_tquery(mysql, query, "", "");
       
        mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `score`=%d, `money`=%d, `kills`=%d, `deaths`=%d, `registered`=%d, `loggedin`=%d, `level`=%d, `cookies`=%d, `cakes`=%d, `biscuits`=%d, `icecreams`=%d, `GT`=%d, `Donator`=%d WHERE `user`='%e'",
        GetPlayerScore(playerid),GetPlayerMoney(playerid),PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths],PlayerInfo[playerid][Registered],PlayerInfo[playerid][LoggedIn],PlayerInfo[playerid][Level],PlayerInfo[playerid][Cookies],PlayerInfo[playerid][Cakes],PlayerInfo[playerid][Biscuits],PlayerInfo[playerid][IceCreams],PlayerInfo[playerid][GT],PlayerInfo[playerid][Donator],pname);
        mysql_tquery(mysql, query, "", "");
       
        mysql_format(mysql, query, sizeof(query), "UPDATE players SET Race=%d, ATMCard=%d, AdminKills=%d, CashToBank=%d, HidenPickUp=%d, VOwner=%d, VOwned=%d,VOwner2=%d ,VOwned2=%d ,VOwner3=%d ,VOwned3=%d ,VOwner4=%d ,VOwned4=%d ,VOwner5=%d ,VOwned5=%d ,VOwner6=%d ,VOwned6=%d WHERE user='%e'",
        PlayerInfo[playerid][RaceWon],PlayerInfo[playerid][ATMCard],PlayerInfo[playerid][AdminKills],PlayerInfo[playerid][CashToBank],PlayerInfo[playerid][HidenPickUp],PlayerInfo[playerid][vowner],PlayerInfo[playerid][vowned],PlayerInfo[playerid][vowner2],PlayerInfo[playerid][vowned2],
        PlayerInfo[playerid][vowner3],PlayerInfo[playerid][vowned3],PlayerInfo[playerid][vowner4],PlayerInfo[playerid][vowned4],PlayerInfo[playerid][vowner5],PlayerInfo[playerid][vowned5],PlayerInfo[playerid][vowner6],PlayerInfo[playerid][vowned6],pname);
        mysql_tquery(mysql, query, "", "");
       
        mysql_format(mysql, query, sizeof(query), "UPDATE players SET Skin=%d, PositionX=%f, PositionY=%f, PositionZ=%f, interior1=%d, TotalCmdsUsed=%d, Complaints=%d, Banned=%d, TotalLogins=%d, TotalKicks=%d, TotalBans=%d, TotalWarnings=%d, ReactionTestWon=%d WHERE user='%e'",
        PlayerInfo[playerid][pSkin],x,y,z,interior,PlayerInfo[playerid][Totcmdsused],PlayerInfo[playerid][pReports],PlayerInfo[playerid][pBanned],PlayerInfo[playerid][Totallogins],PlayerInfo[playerid][Totalkicks],PlayerInfo[playerid][Totalbans],PlayerInfo[playerid][Totalwarnings],PlayerInfo[playerid][ReactionTestWon],pname);
        mysql_tquery(mysql, query, "", "");
       
    }
    return 1;
}
This uses 1600 query size and i set it as a timer to save the data as well as a player leaves but it takes like as i said 5-8 seconds to execute. Could you see anything in this to reduce so that i wont take that long?
Reply


Messages In This Thread
mysql query (small doubt) - by Bondage - 16.01.2015, 15:23
Re: mysql query (small doubt) - by Bondage - 16.01.2015, 16:02
Re: mysql query (small doubt) - by xVIP3Rx - 16.01.2015, 16:26
Re: mysql query (small doubt) - by JeaSon - 16.01.2015, 16:29
Re: mysql query (small doubt) - by Bondage - 16.01.2015, 17:10
Re: mysql query (small doubt) - by xVIP3Rx - 16.01.2015, 17:13
Re: mysql query (small doubt) - by Bondage - 16.01.2015, 17:18
Re: mysql query (small doubt) - by xVIP3Rx - 16.01.2015, 17:22
Re: mysql query (small doubt) - by Bondage - 16.01.2015, 17:29
Re: mysql query (small doubt) - by xVIP3Rx - 16.01.2015, 17:37

Forum Jump:


Users browsing this thread: 2 Guest(s)