SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/08/2018, 01:15 PM   #1
KinderClans
Gangsta
 
KinderClans's Avatar
 
Join Date: May 2018
Location: Italy
Posts: 624
Reputation: 34
Default Save query

I have a problem, this function doesn't save LastLogin, Score and Money. In mysql log LastLogin says: "LastLogin: e", meanwhile score/money to 0.

Other values are saved correctly.

pawn Code:
UpdatePlayerData(playerid)
{
    if(Player[playerid][IsLoggedIn] == false) return 0;

    new query[1300], p = playerid;
    format(query,sizeof(query), "UPDATE `players` SET `LastLogin` = '%e', `Kills` = %d, `Deaths` = %d, `Score` = %i, `Money` = %i, `Level` = %d, `WantedLevel` = %d, `Skin` = %d, `PlayerGender` = %d WHERE `ID`= %d",
    ReturnDate(), Player[p][Kills], Player[p][Deaths], GetPlayerScore(p), GetPlayerMoney(p), Player[p][Level], GetPlayerWantedLevel(p), GetPlayerSkin(p) ,Player[p][PlayerGender], Player[p][ID]);
    mysql_query(g_SQL, query);

    format(query,sizeof(query),"UPDATE `players` SET `PlayingHours` = %d, `PlayingMinutes` = %d, `FirstSpawn` = %d, `Job` = %d, `Bank` = %d, `NoPm` = %d, `Diseases` = %d WHERE `ID`= %d",
    Player[p][PlayingHours], Player[p][PlayingMinutes], Player[p][FirstSpawn], Player[p][Job], Player[p][Bank], Player[p][NoPm], Player[p][Diseases], Player[p][ID]);
    mysql_query(g_SQL, query);

    format(query,sizeof(query), "UPDATE `players` SET `VehicleLicense` = %d, `MotorbikeLicense` = %d, `PlaneLicense` = %d, `HelicopterLicense` = %d, `BankDeposited` = %d, `BankWithdrawal` = %d, `Jailed` = %d, `Warns` = %d WHERE `ID`= %d",
    Player[p][VehicleLicense], Player[p][MotorbikeLicense], Player[p][PlaneLicense], Player[p][HelicopterLicense], Player[p][BankDeposited], Player[p][BankWithdrawal], Player[p][Jailed], Player[p][Warns], Player[p][ID]);
    mysql_query(g_SQL, query);
   
    format(query,sizeof(query),"UPDATE `players` SET `MarijuanaSeeds` = %d, `CocaineSeeds` = %d, `HeroinSeeds` = %d, `Drugs` = %d WHERE `ID`= %d",
    Player[p][MarijuanaSeeds], Player[p][CocaineSeeds], Player[p][HeroinSeeds], Player[p][Drugs], Player[p][ID]);
    mysql_query(g_SQL, query);
    return 1;
}
__________________
LSS RP Discord: https://discord.gg/M9c9PjN

https://is.gd/cheap_vps

Extremely cheap VPS from 5$ monthly (SSD Cached) - Features:

512MB Memory | 500GB Disk Space | 1 TB Transfer | 2 Core Processor | 1 IP Address

Against everyone and everything.

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese... and a large soda.
KinderClans is online now   Reply With Quote
Old 15/08/2018, 01:27 PM   #2
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,292
Reputation: 366
Default Re: Save query

To be able to use %e to escape you gotta use mysql_format not normal format.
jlalt is offline   Reply With Quote
Old 15/08/2018, 01:34 PM   #3
KinderClans
Gangsta
 
KinderClans's Avatar
 
Join Date: May 2018
Location: Italy
Posts: 624
Reputation: 34
Default Re: Save query

Ok and what about score/money?
__________________
LSS RP Discord: https://discord.gg/M9c9PjN

https://is.gd/cheap_vps

Extremely cheap VPS from 5$ monthly (SSD Cached) - Features:

512MB Memory | 500GB Disk Space | 1 TB Transfer | 2 Core Processor | 1 IP Address

Against everyone and everything.

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese... and a large soda.
KinderClans is online now   Reply With Quote
Old 15/08/2018, 01:36 PM   #4
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,292
Reputation: 366
Default Re: Save query

Quote:
Originally Posted by KinderClans View Post
Ok and what about score/money?
They are part of that query as it failing due to %e so none being updated. Use mysql_format and all should be fixed.
jlalt is offline   Reply With Quote
Old 15/08/2018, 01:46 PM   #5
KinderClans
Gangsta
 
KinderClans's Avatar
 
Join Date: May 2018
Location: Italy
Posts: 624
Reputation: 34
Default Re: Save query

Done, now getting argument type mismatch:

pawn Code:
mysql_format(query,sizeof(query), "UPDATE `players` SET `LastLogin` = '%e', `Kills` = %d, `Deaths` = %d, `Score` = %i, `Money` = %i, `Level` = %d, `WantedLevel` = %d, `Skin` = %d, `PlayerGender` = %d WHERE `ID`= %d",
    ReturnDate(), Player[p][Kills], Player[p][Deaths], GetPlayerScore(p), GetPlayerMoney(p), Player[p][Level], GetPlayerWantedLevel(p), GetPlayerSkin(p) ,Player[p][PlayerGender], Player[p][ID]);
    mysql_query(g_SQL, query);
__________________
LSS RP Discord: https://discord.gg/M9c9PjN

https://is.gd/cheap_vps

Extremely cheap VPS from 5$ monthly (SSD Cached) - Features:

512MB Memory | 500GB Disk Space | 1 TB Transfer | 2 Core Processor | 1 IP Address

Against everyone and everything.

I'll have two number 9s, a number 9 large, a number 6 with extra dip, a number 7, two number 45s, one with cheese... and a large soda.
KinderClans is online now   Reply With Quote
Old 15/08/2018, 01:47 PM   #6
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,292
Reputation: 366
Default Re: Save query

First parameter is connection handler.
PHP Code:
mysql_format(g_SQLquery,sizeof(query),...); 
jlalt is offline   Reply With Quote
Old 15/08/2018, 01:48 PM   #7
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 649
Reputation: 133
Default Re: Save query

PHP Code:
mysql_format(g_SQLquery,sizeof(query), "UPDATE `players` SET `LastLogin` = '%e', `Kills` = %d, `Deaths` = %d, `Score` = %i, `Money` = %i, `Level` = %d, `WantedLevel` = %d, `Skin` = %d, `PlayerGender` = %d WHERE `ID`= %d",
    
ReturnDate(), Player[p][Kills], Player[p][Deaths], GetPlayerScore(p), GetPlayerMoney(p), Player[p][Level], GetPlayerWantedLevel(p), GetPlayerSkin(p) ,Player[p][PlayerGender], Player[p][ID]);
    
mysql_query(g_SQLquery); 
iLearner is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query not save to mysql SilverStand Scripting Help 2 23/03/2017 09:20 AM
How can i save various IDs obtained by a SQL ql query in one array Minikole Scripting Help 4 07/02/2016 06:08 PM
Could not save MySQL query O.o venomlivno8 Scripting Help 7 20/02/2014 02:10 PM
Save Query help arko123 Scripting Help 4 02/12/2012 10:01 AM


All times are GMT. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.