SA-MP Forums Archive
Player statistic resetted - 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: Player statistic resetted (/showthread.php?tid=512487)



Player statistic resetted - AiRaLoKa - 11.05.2014

hi all
i got a problem with player's statistic...
sometime the statistic is fine, but sometime it resetted....
what can i do now?
maybe somebody can help me...
u use BlueG's mysql r5

Код:
	mysql_fetch_field_row(savestr, "pWeek");  		pInfo[playerid][pWeek] = strval(savestr);
        mysql_fetch_field_row(savestr, "pDay");  		pInfo[playerid][pDay] = strval(savestr);
        mysql_fetch_field_row(savestr, "pHour");        pInfo[playerid][pHour] = strval(savestr);
        mysql_fetch_field_row(savestr, "pMin");         pInfo[playerid][pMin] = strval(savestr);
	mysql_fetch_field_row(savestr, "pSec");     	pInfo[playerid][pSec] = strval(savestr);
on mysql_log.txt

Код:
[12:03:43] >> mysql_fetch_field_row( Connection handle: 1 )
[12:03:43] CMySQLHandler::FetchField("pWeek") - 0
[12:03:43] >> mysql_fetch_field_row( Connection handle: 1 )
[12:03:43] CMySQLHandler::FetchField("pDay") - 3
[12:03:43] >> mysql_fetch_field_row( Connection handle: 1 )
[12:03:43] CMySQLHandler::FetchField("pHour") - 1
[12:03:43] >> mysql_fetch_field_row( Connection handle: 1 )
[12:03:43] CMySQLHandler::FetchField("pMin") - 48
[12:03:43] >> mysql_fetch_field_row( Connection handle: 1 )
[12:03:43] CMySQLHandler::FetchField("pSec") - 9



Re: Player statistic resetted - Calgon - 11.05.2014

Does the player lose all stats or just the ones you've pasted?


Re: Player statistic resetted - AiRaLoKa - 11.05.2014

they just loose that i've pasted
but sometime they loose the cash and score..


Re: Player statistic resetted - Calgon - 11.05.2014

A fairly common problem with MySQL gamemodes is that user accounts are saved over if a new account connects before the saving query fully executes.

You can prevent this from happening by avoiding the use of any variables which reset a connecting players stats until the saving query has completely finished. Alternatively, you could write one incredibly long query which sends the information immediately as the player disconnects (which would require an incredibly long string for a large player account update) or you could use SQL transactions.


Re: Player statistic resetted - AiRaLoKa - 11.05.2014

can you give me the example?
i know what you mean but i dont know what to do....


Re: Player statistic resetted - Calgon - 11.05.2014

The simplest example would be SQL transactions, as you wouldn't need to change any code apart from the saving code, the resetting stuff won't have to be done.

For this, you need to format and send all of your SQL queries at the same time and within the same function.

I won't write the code for you, but hopefully that is a good explanation.

By the way, it's possible this isn't the problem. Just a likely cause, still worth fixing regardless.


Re: Player statistic resetted - AiRaLoKa - 11.05.2014

if i do that, it will get a big sized string....
and it will make my server lag....


Re: Player statistic resetted - Calgon - 11.05.2014

Quote:
Originally Posted by AiRaLoKa
Посмотреть сообщение
if i do that, it will get a big sized string....
and it will make my server lag....
If you use transactions you don't need a big sized string. You format one string, send the query as a part of a transaction, then continue doing so until you've sent all of your information as transactions, then you finalize the transaction.

It's like opening a file, you read line by line for what you're looking for, then when you're done, you close it. Transactions basically let you queue queries and send it all at once. You can thread a response later on.

Regardless of this, "big sized string[s]" do not lag your server. They consume memory which does not cause any CPU problems or any noticable lag.


Re: Player statistic resetted - AiRaLoKa - 11.05.2014

got it...

thanks for your help...
+REP