Impossible to save stats
#1

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
Reply
#2

PHP Code:
new string12[128];
format(string12sizeof(string12), "UPDATE users SET skin_player='%d' WHERE id='%i'"GetPlayerSkin(playerid), Player[playerid][ID]);
mysql_function_query(g_SQLstring12false""""); 
Im using this Kind of UPDATE.


Hope it helps
Reply
#3

Check the log for any errors and post here.
Reply
#4

Quote:
Originally Posted by Logok987
View Post
PHP Code:
new string12[128];
format(string12sizeof(string12), "UPDATE users SET skin_player='%d' WHERE id='%i'"GetPlayerSkin(playerid), Player[playerid][ID]);
mysql_function_query(g_SQLstring12false""""); 
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
View Post
Check the log for any errors and post here.
I don't have errors :/
Reply
#5

Try this.
PHP Code:
UpdatePlayerData(playerid)
{
    if(
Player[playerid][IsLoggedIn] == true)
    {
        new 
query[600];
        
mysql_format(g_SQLquerysizeof(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_SQLquery);
        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.
Reply
#6

Quote:
Originally Posted by aoky
View Post
Try this.
PHP Code:
UpdatePlayerData(playerid)
{
    if(
Player[playerid][IsLoggedIn] == true)
    {
        new 
query[600];
        
mysql_format(g_SQLquerysizeof(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_SQLquery);
        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
Reply
#7

Quote:
Originally Posted by Klayton
View Post
does not work bro
Can you show us your mysql_log.txt, please.
Reply
#8

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
Reply
#9

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.
Reply
#10

Can you send a full screenshot of your database tables?
Reply
#11

Quote:
Originally Posted by Konstantinos
View Post
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
Reply
#12

Not that, I mean where it shows players etc.
Reply
#13

Quote:
Originally Posted by aoky
View Post
Not that, I mean where it shows players etc.
That ? http://prntscr.com/hq3bcx
Reply
#14

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.
Reply
#15

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)
Reply
#16

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.
Reply
#17

Oh yeah !
Fucking idiot I am..
Thanks bro !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)