SA-MP Forums Archive
MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - 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: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! (/showthread.php?tid=579202)



MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - STONEGOLD - 25.06.2015

Well, I added more in saving system of mysql but it says The line is too long.

Here you can see the code. It says the ling is too long so then i tried something new but got error. So, I wanted to post it here cuz i want get something best from pro scripters. Thanks.

PHP Code:
///mysql start
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, `Medical`=%d WHERE `ID`=%d AND `user`='%e'",
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pVip],
        
GetPlayerMoney(playerid),
        
GetPlayerScore(playerid),
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][pKills],
        
pInfo[playerid][pHitsCompleted],
        
GetPlayerSkin(playerid),
        
pInfo[playerid][pRobbed],
        
pInfo[playerid][pRobbedMoney],
        
pInfo[playerid][pGotRobbed],
        
pInfo[playerid][pGotRobbedMoney],
        
pInfo[playerid][pStoreRobbed],
        
pInfo[playerid][pStoreRobbedMoney],
        
pInfo[playerid][pFoodPurchased],
        
pInfo[playerid][pFoodPurchasedMoney],
        
pInfo[playerid][pWeaponsPurchased],
        
pInfo[playerid][pWeaponsPurchasedMoney],
        
pInfo[playerid][pHealed],
        
pInfo[playerid][pArrest],
        
pInfo[playerid][pBusted],
        
pInfo[playerid][pCrimes],
        
pInfo[playerid][pWantedLevel],
        
pInfo[playerid][pDrugs],
        
pInfo[playerid][pMedical],
        
pInfo[playerid][pID],
        
PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        print(
query);
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `IsBanned`=%d WHERE `ID`=%d AND user='%e'"pInfo[playerid][pIsBanned], PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        
IsLoggedIn[playerid] = 0;
        if(
pInfo[playerid][pAdmin] >= 1)
        {
            
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'"pInfo[playerid][pAName]);
            return 
true;
        }
    }
    return 
1;

PHP Code:
5475) : error 075input line too long (after substitutions
Then i tried this tho it would work but didn't work still got error and i think it's wrong. Do you have any idea?

PHP Code:
forward OnPlayerSave(playerid);
public 
OnPlayerSave(playerid)
{
    new 
query[500];
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid))
    {
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, \
        `Medical`=%d WHERE `ID`=%d AND `user`='%e'"
,
        
pInfo[playerid][pAdmin],
        
pInfo[playerid][pVip],
        
GetPlayerMoney(playerid),
        
GetPlayerScore(playerid),
        
pInfo[playerid][pDeaths],
        
pInfo[playerid][pKills],
        
pInfo[playerid][pHitsCompleted],
        
GetPlayerSkin(playerid),
        
pInfo[playerid][pRobbed],
        
pInfo[playerid][pRobbedMoney],
        
pInfo[playerid][pGotRobbed],
        
pInfo[playerid][pGotRobbedMoney],
        
pInfo[playerid][pStoreRobbed],
        
pInfo[playerid][pStoreRobbedMoney],
        
pInfo[playerid][pFoodPurchased],
        
pInfo[playerid][pFoodPurchasedMoney],
        
pInfo[playerid][pWeaponsPurchased],
        
pInfo[playerid][pWeaponsPurchasedMoney],
        
pInfo[playerid][pHealed],
        
pInfo[playerid][pArrest],
        
pInfo[playerid][pBusted],
        
pInfo[playerid][pCrimes],
        
pInfo[playerid][pWantedLevel],
        
pInfo[playerid][pDrugs],
        
pInfo[playerid][pMedical],
        
pInfo[playerid][pID],
        
PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        print(
query);
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `IsBanned`=%d WHERE `ID`=%d AND user='%e'"pInfo[playerid][pIsBanned], PlayerName(playerid));
        
mysql_tquery(MySQLConquery"""");
        
IsLoggedIn[playerid] = 0;
        if(
pInfo[playerid][pAdmin] >= 1)
        {
            
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `AdminName`=%s WHERE `ID`=%d AND `user`='%e'"pInfo[playerid][pAName]);
            return 
true;
        }
    }
    return 
1;




Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - AndySedeyn - 25.06.2015

I think Zeex's compiler patches fixed that: https://github.com/Zeex/pawn


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - STONEGOLD - 25.06.2015

Oh! Thanks bro. But any idea how to fix it in this pwno?


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - AndySedeyn - 25.06.2015

Split it up in different queries, like you did with the banned data. Note that, that does not work with 'INSERT INTO' though.


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - prineside - 25.06.2015

I used that "technique" to build long query strings:

PHP Code:
new query[1024]; // long string with sql query
new tmp[64];
formatquery1024"UPDATE players SET " );
formattmp64"age = %i, "player[playerid][AGE] );
strcatquerytmp );
formattmp64"health = %0.2f, "player[playerid][HEALTH] );
strcatquerytmp );
// ...
formattmp64"money = %i "player[playerid][MONEY] );
strcatquerytmp );
formattmp64"WHERE id = %i;"player[playerid][BASEID] );
strcatquerytmp );
mysql_querymysqlquery ); 



Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - STONEGOLD - 25.06.2015

Oh! Yeah i have searched on forum and got this method. But I want to know from a good scripters is it good if i use like this? But I would like to have a solution in my method. Anyone?


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - prineside - 25.06.2015

Quote:
Originally Posted by STONEGOLD
View Post
Oh! Yeah i have searched on forum and got this method. But I want to know from a good scripters is it good if i use like this? But I would like to have a solution in my method. Anyone?
What you mean saying "good"?
Maybe in case of very large query in will be 1-2ms slower than using one format() up to 512 characters. I use that for my life and never got any problems.

Good:
+ You can create very large queries without reaching 512 char line limit
+ Everything is clear, you will probably never make a mistake in format() arguments order
+ It's the only way to format a big query and to execute it without splitting into smaller ones
+ Mysql server executes only one query - it's a big +

Bad:
- It uses +64 cells of memory for tmp var
- Someone suggested not to create long strings, but I think that a frw bytes of wasted memory is better than ten Mysql queries.


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - STONEGOLD - 25.06.2015

AH thanks, Can you make it like this. I want to see how does it look like so i can code it

PHP Code:
forward OnPlayerSave(playerid); 
public 
OnPlayerSave(playerid

    new 
query[500]; 
    if(
IsLoggedIn[playerid] == && playerid != INVALID_PLAYER_ID && !IsPlayerNPC(playerid)) 
    { 
        
mysql_format(MySQLConquerysizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `Deaths`=%d, `Kills`=%d, `HitsCompleted`=%d, `SkinID`=%d, `Robbed`=%d, `RobbedMoney`=%d, `GotRobbed`=%d, `GotRobbedMoney`=%d, `StoreRobbed`=%d, `StoreRobbedMoney`=%d, `FoodPurchased`=%d, `FoodPurchasedMoney`=%d, `WeaponsPurchased`=%d, `WeaponsPurchasedMoney`=%d, `Healed`=%d, `Arrest`=%d, `Busted`=%d, `Crimes`=%d, `WantedLevel`=%d, `Drugs`=%d, \ 
        `Medical`=%d WHERE `ID`=%d AND `user`='%e'"

        
pInfo[playerid][pAdmin], 
        
pInfo[playerid][pVip], 
        
GetPlayerMoney(playerid), 
        
GetPlayerScore(playerid), 
        
pInfo[playerid][pDeaths], 
        
pInfo[playerid][pKills], 
        
pInfo[playerid][pHitsCompleted], 
Just make it look like this for exmaple. Thanks!


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - STONEGOLD - 25.06.2015

BUmp


Re: MYSQL SAVING ERROR (NEED IT URGENT) Thanks! - Vince - 25.06.2015

How many times I have to say it? Do not save everything at once if you can help it. How often does the admin level change? Or the VIP level? Or ...? Once per year or so? What good does it do updating something that hasn't changed?

Update stuff when it changes and you will have far more concise queries and less troubles.