Impossible to save stats -
Klayton - 20.12.2017
Hello guys, I use a r39-6 mysql (the source script example), and I add a stat (skin_player), and when I use /setskin with UpdatePlayerData(id) , the new value he don't save in my .sql, why ?
http://prntscr.com/hpubq4
Re: Impossible to save stats -
Logok987 - 20.12.2017
PHP Code:
new string12[128];
format(string12, sizeof(string12), "UPDATE users SET skin_player='%d' WHERE id='%i'", GetPlayerSkin(playerid), Player[playerid][ID]);
mysql_function_query(g_SQL, string12, false, "", "");
Im using this Kind of UPDATE.
Hope it helps
Re: Impossible to save stats -
DelK - 20.12.2017
Check the log for any errors and post here.
Re: Impossible to save stats -
Klayton - 20.12.2017
Quote:
Originally Posted by Logok987
PHP Code:
new string12[128];
format(string12, sizeof(string12), "UPDATE users SET skin_player='%d' WHERE id='%i'", GetPlayerSkin(playerid), Player[playerid][ID]);
mysql_function_query(g_SQL, string12, false, "", "");
Im using this Kind of UPDATE.
Hope it helps
|
Yeah but I want use UpdatePlayerData for save all stats of player you know
Quote:
Originally Posted by DelK
Check the log for any errors and post here.
|
I don't have errors :/
Re: Impossible to save stats -
aoky - 20.12.2017
Try this.
PHP Code:
UpdatePlayerData(playerid)
{
if(Player[playerid][IsLoggedIn] == true)
{
new query[600];
mysql_format(g_SQL, query, sizeof(query, "UPDATE `players` SET `skin_player` = '%d', `cash` = '%d WHERE `id` = '%d' LIMIT 1",
Player[playerid][Skin_Player],
Player[playerid][Cash],
Player[playerid][ID]);
mysql_tquery(g_SQL, query);
return 1;
}
}
And don't post screenshots of your code, please use pastebin or just post the code in the PHP feature on the forums.
Re: Impossible to save stats -
Klayton - 20.12.2017
Quote:
Originally Posted by aoky
Try this.
PHP Code:
UpdatePlayerData(playerid)
{
if(Player[playerid][IsLoggedIn] == true)
{
new query[600];
mysql_format(g_SQL, query, sizeof(query, "UPDATE `players` SET `skin_player` = '%d', `cash` = '%d WHERE `id` = '%d' LIMIT 1",
Player[playerid][Skin_Player],
Player[playerid][Cash],
Player[playerid][ID]);
mysql_tquery(g_SQL, query);
return 1;
}
}
And don't post screenshots of your code, please use pastebin or just post the code in the PHP feature on the forums.
|
does not work bro
.pwn ->
https://pastebin.com/pu0Kjcas
Re: Impossible to save stats -
aoky - 20.12.2017
Quote:
Originally Posted by Klayton
does not work bro
|
Can you show us your mysql_log.txt, please.
Re: Impossible to save stats -
Klayton - 20.12.2017
Oh yeah I have one error , but I don't understand
Log:
http://prntscr.com/hq3645 (.html )
.pwn ->
https://pastebin.com/pu0Kjcas
databse:
http://prntscr.com/hq36hx |
http://prntscr.com/hq36ke
Re: Impossible to save stats -
Konstantinos - 20.12.2017
Code:
"UPDATE `players` SET `skin_player` = '%d', `cash` = '%d' WHERE `id` = '%d' LIMIT 1"
Wrap the values inside ' ' when using strings. Integers and floating-point numbers are unnecessary. Also if
id is
PRIMARY KEY (which should be), using
LIMIT clause is pointless too.
Re: Impossible to save stats -
aoky - 20.12.2017
Can you send a full screenshot of your database tables?
Re: Impossible to save stats -
Klayton - 20.12.2017
Quote:
Originally Posted by Konstantinos
Code:
"UPDATE `players` SET `skin_player` = '%d', `cash` = '%d' WHERE `id` = '%d' LIMIT 1"
Wrap the values inside ' ' when using strings. Integers and floating-point numbers are unnecessary. Also if id is PRIMARY KEY (which should be), using LIMIT clause is pointless too.
|
Does not work with this:
https://pastebin.com/NY3yQvbj
EDIT
Full database:
http://prntscr.com/hq39ma
Re: Impossible to save stats -
aoky - 20.12.2017
Not that, I mean where it shows players etc.
Re: Impossible to save stats -
Klayton - 20.12.2017
Quote:
Originally Posted by aoky
Not that, I mean where it shows players etc.
|
That ?
http://prntscr.com/hq3bcx
Re: Impossible to save stats -
Konstantinos - 20.12.2017
UpdatePlayerData uses
Player[playerid][Skin_Player] and
Player[playerid][Cash] in
mysql_format which are both 0 because you didn't set any value in
/setskin or
/givemoney commands before calling the function.
Re: Impossible to save stats -
Klayton - 20.12.2017
Yeah but I have everytime use with this syntax and I have never problem, this first time and I don't understand oO
(This script is source-script of github mysql r39-6)
Re: Impossible to save stats -
Konstantinos - 20.12.2017
Except the missing single quote that gave syntax error after modifying it, the query itself is working. The problem of not updating the database is that you never assign the new value to the variables:
Code:
CMD:setskin(playerid, params[])
{
new playerb, value;
if (sscanf(params, "ui", playerb, value))
return SendClientMessage(playerid, -1, "{88AA88}/setskin {FFFFFF}[playerid/nom] [id skin]");
GameTextForPlayer(playerid, "nouveau skin", 1000, 1);
SetPlayerSkin(playerb, value);
Player[playerb][Skin_Player] = value;
UpdatePlayerData(playerid);
return 1;
}
CMD:givemoney(playerid, params[])
{
new playerb, value;
if (sscanf(params, "ui", playerb, value))
return SendClientMessage(playerid, -1, "{88AA88}/givemoney {FFFFFF}[playerid/nom] [somme]");
GameTextForPlayer(playerid, "nouveau skin", 1000, 1);
GivePlayerMoney(playerb, value);
Player[playerb][Cash] = value;
UpdatePlayerData(playerid);
return 1;
}
so it just re-updated those two columns with the value of 0.
On another note, please check if
playerb is valid (connected) player before using it in arrays to avoid
run time error 4.
Re: Impossible to save stats -
Klayton - 20.12.2017
Oh yeah !
Fucking idiot I am..
Thanks bro !