SA-MP Forums Archive
Query too long - 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: Query too long (/showthread.php?tid=522689)



Query too long - Jimmy0wns - 28.06.2014

Is there any way to make this query any shorter, tried multiple things but they didn't work either.

pawn Код:
SavePlayer(playerid)
{
    if(pInfo[playerid][Logged] == 1)
    {
        new Query[1500];
        format(Query, 1500, "UPDATE `members` SET `admin` = '%d', `score` = '%d', `money` = '%d', `exp` = '%d', `level` = '%d',`kills` = '%d', `deaths` = '%d', `weapon1` = '%d', `ammo1` = '%d', `weapon2` = '%d', `ammo2` = '%d', `weapon3` = '%d', `ammo3` = '%d', `weapon4` = '%d', `ammo4` = '%d', `weapon5` = '%d', `ammo5` = '%d', `weapon6` = '%d', `ammo6` = '%d', `weapon7` = '%d', `ammo7` = '%d', `weapon8` = '%d', `ammo8` = '%d', `weapon9` = '%d', `ammo9` = '%d', `weapon10` = '%d', `ammo10` = '%d', `weapon11` = '%d', `ammo11` = '%d', `weapon12` = '%d', `ammo12` = '%d' WHERE `id` = '%d' LIMIT 1",
        pInfo[playerid][pAdmin],
        pInfo[playerid][pScore],
        pInfo[playerid][pMoney],
        pInfo[playerid][pExp],
        pInfo[playerid][pLevel],
        pInfo[playerid][pKills],
        pInfo[playerid][pDeaths],
        pInfo[playerid][pAmmo1],
        pInfo[playerid][pWeapon2],
        pInfo[playerid][pAmmo2],
        pInfo[playerid][pWeapon3],
        pInfo[playerid][pAmmo3],
        pInfo[playerid][pWeapon4],
        pInfo[playerid][pAmmo4],
        pInfo[playerid][pWeapon5],
        pInfo[playerid][pAmmo5],
        pInfo[playerid][pWeapon6],
        pInfo[playerid][pAmmo6],
        pInfo[playerid][pWeapon7],
        pInfo[playerid][pAmmo7],
        pInfo[playerid][pWeapon8],
        pInfo[playerid][pAmmo8],
        pInfo[playerid][pWeapon9],
        pInfo[playerid][pAmmo9],
        pInfo[playerid][pWeapon10],
        pInfo[playerid][pAmmo10],
        pInfo[playerid][pWeapon11],
        pInfo[playerid][pAmmo11],
        pInfo[playerid][pWeapon12],
        pInfo[playerid][pAmmo12],
        pInfo[playerid][ID]);
        mysql_query(Query);
    }
}



Re: Query too long - sammp - 28.06.2014

Split it up into different queries, such as Query2, Query3 etc


Re: Query too long - Jimmy0wns - 28.06.2014

Ah yeah, thanks!


Re: Query too long - Vince - 28.06.2014

https://sampforum.blast.hk/showthread.php?tid=505081


Re: Query too long - Jimmy0wns - 29.06.2014

Quote:
Originally Posted by Vince
Посмотреть сообщение
I already checked it out but I'm using Strickenkid's MySQL plugin and I don't know how to convert your script.


Re: Query too long - Haydz - 29.06.2014

Hey Jimmy, it's been awhile ! Another way would be removing a few of what you're saving and save them separately when they need to be saved.

E.G
`admin` - You'd only need to save that whenever it gets changed, so upon the promoting / demoting admin command just save it then.
`score` - Depending how often a player gets score it might not really matter but you could create your own score function and save the new score var when they're given a score.
`money` - Similar to above, save the players money value whenever they gain / lose money. This way their money data will be up to date if the server happens to crash and the server can't save the data that occoured after the last saving point.

Exp, Level, Kills Deaths - You get the point, save it when the player gets killed / kills somebody else.

Now your query is only 419 characters long, allow some space for the larger values (many 50-80 characters or so). There's nothing wrong with a decent sized query, it has to be saved somehow lol.

pawn Код:
UPDATE `members` SET `weapon1` = %d, `ammo1` = %d, `weapon2` = %d, `ammo2` = %d, `weapon3` = %d, `ammo3` = %d, `weapon4` = %d, `ammo4` = %d, `weapon5` = %d, `ammo5` = %d, `weapon6` = %d, `ammo6` = %d, `weapon7` = %d, `ammo7` = %d, `weapon8` = %d, `ammo8` = %d, `weapon9` = %d, `ammo9` = %d, `weapon10` = %d, `ammo10` = %d, `weapon11` = %d, `ammo11` = %d, `weapon12` = %d, `ammo12` = %d WHERE `id` = %d LIMIT 1



Re: Query too long - Jimmy0wns - 29.06.2014

Quote:
Originally Posted by Haydz
Посмотреть сообщение
Hey Jimmy, it's been awhile ! Another way would be removing a few of what you're saving and save them separately when they need to be saved.

E.G
`admin` - You'd only need to save that whenever it gets changed, so upon the promoting / demoting admin command just save it then.
`score` - Depending how often a player gets score it might not really matter but you could create your own score function and save the new score var when they're given a score.
`money` - Similar to above, save the players money value whenever they gain / lose money. This way their money data will be up to date if the server happens to crash and the server can't save the data that occoured after the last saving point.

Exp, Level, Kills Deaths - You get the point, save it when the player gets killed / kills somebody else.

Now your query is only 419 characters long, allow some space for the larger values (many 50-80 characters or so). There's nothing wrong with a decent sized query, it has to be saved somehow lol.

pawn Код:
UPDATE `members` SET `weapon1` = %d, `ammo1` = %d, `weapon2` = %d, `ammo2` = %d, `weapon3` = %d, `ammo3` = %d, `weapon4` = %d, `ammo4` = %d, `weapon5` = %d, `ammo5` = %d, `weapon6` = %d, `ammo6` = %d, `weapon7` = %d, `ammo7` = %d, `weapon8` = %d, `ammo8` = %d, `weapon9` = %d, `ammo9` = %d, `weapon10` = %d, `ammo10` = %d, `weapon11` = %d, `ammo11` = %d, `weapon12` = %d, `ammo12` = %d WHERE `id` = %d LIMIT 1
That will help me out a bit more, thanks Hayden!