SA-MP Forums Archive
MySQL saving - 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 (/showthread.php?tid=534570)



MySQL saving - finelaq - 30.08.2014

Hi, im a new in MySQL and i wanted to save drift score in database, but it don't work. I tried many ways..

Code:
pawn Код:
{
public DriftCancellation(playerid)
{
    PlayerDriftCancellation[playerid] = 0;
    AnnaRaha(playerid,DriftPointsNow[playerid],0);
    new query[300], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid]);
    DriftPointsNow[playerid] = 0;
    DriftPoints[playerid] = 0;
    scores[playerid] = 0;
    TextDrawHideForPlayer(playerid, Chet[playerid]);
    TextDrawHideForPlayer(playerid, ChetP[playerid]);
}
If you want more codes or something then tell me...

In phpmyadmin it don't work:

Hope you see pic


Re: MySQL saving - Wizzy951 - 30.08.2014

What version of MySQL plugin are you using ? Try adding this line
pawn Код:
//below
format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid]);
//the following line
mysql_function_query(YourDatabaseName, query, false, "", "");

//above
DriftPointsNow[playerid] = 0;
Edit: my code works for r7 and versions above.


Re: MySQL saving - finelaq - 30.08.2014

Quote:
Originally Posted by Wizzy951
Посмотреть сообщение
What version of MySQL plugin are you using ? Try adding this line
pawn Код:
//below
format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid]);
//the following line
mysql_function_query(YourDatabaseName, query, false, "", "");

//above
DriftPointsNow[playerid] = 0;
Im using R6


Re: MySQL saving - BroZeus - 30.08.2014

use this one
pawn Код:
public DriftCancellation(playerid)
{
    PlayerDriftCancellation[playerid] = 0;
    AnnaRaha(playerid,DriftPointsNow[playerid],0);
    new query[300], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid], pname);
    mysql_query(query);//u forgot this line
    DriftPointsNow[playerid] = 0;
    DriftPoints[playerid] = 0;
    scores[playerid] = 0;
    TextDrawHideForPlayer(playerid, Chet[playerid]);
    TextDrawHideForPlayer(playerid, ChetP[playerid]);
}



Re: MySQL saving - finelaq - 30.08.2014

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
use this one
pawn Код:
public DriftCancellation(playerid)
{
    PlayerDriftCancellation[playerid] = 0;
    AnnaRaha(playerid,DriftPointsNow[playerid],0);
    new query[300], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid], pname);
    mysql_query(query);//u forgot this line
    DriftPointsNow[playerid] = 0;
    DriftPoints[playerid] = 0;
    scores[playerid] = 0;
    TextDrawHideForPlayer(playerid, Chet[playerid]);
    TextDrawHideForPlayer(playerid, ChetP[playerid]);
}
Thanks man... It work now.


Re: MySQL saving - Fred1993 - 30.08.2014

format(query, sizeof(query), "UPDATE `playerdata` SET Drift='%i' WHERE user='%s'", DriftPoints[playerid], PlayerNameHere);
mysql_function_query(g_mysql_handle, query, true, "EmptyCallback", "");

//below code is to connect sql and store the info in g_mysql_handle.
g_mysql_handle = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_DATABASE ,MYSQL_PASSWORD);
// use this at your game mode in the top.