[MySQL] Score, money resetting?
#1

Hi all. Im using BlueG' s MySQL R39-2 plugin.
Sometimes players' s score and money get reset. But just score and money. (Other variables not resetting). What is the problem and How can i fix this? Please help me..
Reply
#2

Are there any idea? Please help me...
Reply
#3

Maybe youre variables are resetting and get saved in to the database.
Reply
#4

Is there any other ideas?
Reply
#5

Well, you should at least show us your code, where you save and load money and score, so we can help you better
Reply
#6

I couldn't find any problem in code. Please help..
Код:
//onplayerconnect

new query[512];
    Logged[playerid] = 0;
	mysql_format(mysql, query, sizeof(query),"SELECT `hash`, `id` FROM `users` WHERE `name` = '%e' LIMIT 1", PlayerName(playerid));
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);



//onaccountcheck
public OnAccountCheck(playerid)
{
    new rows, fields;
    cache_get_data(rows, fields, mysql);
    if(rows)
    {
        cache_get_field_content(0, "hash", pPassword[playerid], mysql, 65);
        UserID[playerid] = cache_get_field_content_int(0, "id");
      //showlogin dialog
    }
    else
    {
   //showregister dialog
    }
    return 1;
}


//logindialog
case DIALOG_LOGIN:
    {
        if(!response) return Kick(playerid);
   			new hash[64];
            SHA256_PassHash(inputtext, "", hash, 65);
      		if(!strcmp(hash, pPassword[playerid]))
       		{
                new query[1024];
         		mysql_format(mysql, query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%e' LIMIT 1", PlayerName(playerid));
          		mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
          		SendInfo(playerid,"Logged in.");
          		CheckBan(playerid);
			}


//onaccountregister
public OnAccountRegister(playerid)
{
    UserID[playerid] = cache_insert_id();
    return 1;
}

//onaccountload
public OnAccountLoad(playerid)
{
		pScore[playerid] =cache_get_field_content_int(0, "score");
		pCash[playerid] =cache_get_field_content_int(0, "cash");

//... other variables

Logged[playerid]=1;
GivePlayerMoney(playerid,pCash[playerid];
SetPlayerScore(playerid,pScore[playerid];
return 1;
}

//saveaccountstats
public SaveAccountStats(playerid)
{
	if(Logged[playerid] == 1)
{
		pScore[playerid] = GetPlayerScore(playerid);
		pCash[playerid] = GetPlayerMoney(playerid);
		mysql_format(mysql, query, sizeof(query), "UPDATE `users` SET `cash`=%d, `score`=%d WHERE `id`=%d",pCash[playerid],pScore[playerid],UserID[playerid]);
		mysql_tquery(mysql, query, "", "");
		return 1;
	}
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)