SA-MP Forums Archive
Samp Server /Stats Problem - 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: Samp Server /Stats Problem (/showthread.php?tid=655823)



Samp Server /Stats Problem - Cezar98 - 30.06.2018

From time to time, any account that register on server has this problem

https://www.imgx.ro/fullview.php?id=243040

Kills 48, Killing Spree 101 and others. And it's not normal because in mysql data base
all are setted to zero and when player login to the server have that problem

the mysql database of the server https://www.imgx.ro/fullview.php?id=243042

register code

https://www.imgx.ro/fullview.php?id=243043

Save Player Data

SavePlayer(playerid)
{
new h, m, s, szYear, szMonth, szDay;
//--------------------------------------------------------------------------
TotalGameTime(playerid, h, m, s);
//--------------------------------------------------------------------------
getdate(szYear, szMonth, szDay);
//--------------------------------------------------------------------------
eString[0] = EOS; eQuery[0] = EOS;
//--------------------------------------------------------------------------
format(eString, sizeof(eString), "UPDATE `Accounts` SET `LoggedIn` = 0, `LastOn` = '%02d/%02d/%02d', `Level` = '%d', `VIP` = '%d', `Cash` = '%d', `Score` = '%d', Coins = '%d', `Headshots` = '%s', `Kills` = '%s', `Deaths` = '%s', `Hours` = '%d', `Minutes` = '%d', `Seconds` = '%d', `BestKillings` = '%d', `Gifts` = '%d', `Gems` = '%d', `Warnings` = '%d', `MemberSkin` = '%d', `GangTank` = '%d'", szDay, szMonth, szYear, CosminInfo[playerid][Level], CosminInfo[playerid][pVIP], GetPlayerMoney(playerid), GetPlayerScore(playerid), CosminInfo[playerid][Coins], CosminInfo[playerid][Headshots], CosminInfo[playerid][Kills], CosminInfo[playerid][Deaths], h, m, s, CosminInfo[playerid][BestKillingSpree], CosminInfo[playerid][Gifts], CosminInfo[playerid][Gems], CosminInfo[playerid][Warnings], CosminInfo[playerid][MemberSkin2], CosminInfo[playerid][GangTank]);
//--------------------------------------------------------------------------
format(eString, sizeof(eString), "%s, `House` = '%d', `Property` = '%d', `Description1` = '%s', `Description2` = '%s', `Description3` = '%s', `Positive` = '%d', `Negative` = '%d', `DriftMonth` = '%d', `KillsMonth` = '%d', `block` = '%d'", eString, CosminInfo[playerid][House], CosminInfo[playerid][Property], CosminInfo[playerid][DLine1], CosminInfo[playerid][DLine2], CosminInfo[playerid][DLine3], CosminInfo[playerid][PosRespect], CosminInfo[playerid][NegRespect], CosminInfo[playerid][DriftMonth], CosminInfo[playerid][KillsMonth], CosminInfo[playerid][block]);
//--------------------------------------------------------------------------
format(eString, sizeof(eString), "%s, `Kicks` = '%d', `Bans` = '%d', `Jails` = '%d', `Warns` = '%d', `ClearChats` = '%d', `ReactionTest` = '%d', `MathTest` = '%d', `Mutes` = '%d', `Jailed` = '%d', `Frozen` = '%d', `Muted` = '%d', `HoursMonth` = '%d', `MinutesMonth` = '%d', `SecondsMonth` = '%d'", eString, CosminInfo[playerid][PKicks], CosminInfo[playerid][PBans], CosminInfo[playerid][PJails], CosminInfo[playerid][PWarns], CosminInfo[playerid][PClearCH], CosminInfo[playerid][PReactions], CosminInfo[playerid][PMaths], CosminInfo[playerid][PMutes], CosminInfo[playerid][Jailed], CosminInfo[playerid][Frozen], fTime[playerid][0], fTime[playerid][1], CosminInfo[playerid][Muted], mTime[playerid][0], mTime[playerid][1], CosminInfo[playerid][hoursMonth], CosminInfo[playerid][minsMonth], CosminInfo[playerid][secsMonth]);
//--------------------------------------------------------------------------
format(eString, sizeof(eString), "%s, `RaceScore` = '%d', `StuntScore` = '%d', `DriftScore` = '%d', `AdmWarns` = '%d', `VIPWarns` = '%d', `KickW` = '%d', `LottoNumber` = '%d', `C4` = '%d', `StatsNote` = '%d', `TempVIP` = '%d', `Activity` = '%d', `RaceMonth` = '%d'", eString, CosminInfo[playerid][RacePoints], CosminInfo[playerid][StuntPoints], CosminInfo[playerid][DriftPoints], CosminInfo[playerid][AdmW], CosminInfo[playerid][VIPW], CosminInfo[playerid][KickW], CosminInfo[playerid][LottoNumber], CosminInfo[playerid][C4], GiveNote(playerid), CosminInfo[playerid][TVip], CosminInfo[playerid][Activity], CosminInfo[playerid][RaceMonth]);
//--------------------------------------------------------------------------
format(eString, sizeof(eString), "%s, `GangID` = '%d', `GangRank` = '%d', `GangSkin` = '%d', `GangKills` = '%d', `GangDeaths` = '%d', `GangWarns` = '%d', `GangCaptures` = '%d', `StuntMonth` = '%d', `GangPoints` = '%d', `ClanID` = '%d', `ClanRank` = '%d' WHERE `ID` = '%d'", eString, CosminInfo[playerid][GangID], CosminInfo[playerid][g_Rank], CosminInfo[playerid][g_Skin], CosminInfo[playerid][g_Kills], CosminInfo[playerid][g_Deaths], CosminInfo[playerid][g_Warns], CosminInfo[playerid][g_Captures], CosminInfo[playerid][StuntMonth], CosminInfo[playerid][g_Points], CosminInfo[playerid][ClanID], CosminInfo[playerid][ClanRank ], CosminInfo[playerid][AccID]);
//--------------------------------------------------------------------------
mysql_tquery(DB_Connect, eString, "", "");


Re: Samp Server /Stats Problem - Calisthenics - 30.06.2018

Reset variables (arrays per-player) in OnPlayerConnect. Otherwise new registered players will have the stats of previous player.

It seems you forgot these two:
pawn Код:
// OnPlayerConnect:
CosminInfo[playerid][Kills] = 0;
CosminInfo[playerid][BestKillingSpree] = 0;



Re: Samp Server /Stats Problem - Cezar98 - 30.06.2018

All are reseted and no results

https://www.imgx.ro/fullview.php?id=243044


Re: Samp Server /Stats Problem - Calisthenics - 30.06.2018

Post the code that shows the dialog in the first picture. Perhaps you have misplaced the arguments.

EDIT: Why do you set as string for kills?
pawn Код:
`Kills` = '%s'
Kills are integer and it needs to be %d

Yes, this is the problem. 0 in ASCII is 48, it takes it as character.


Re: Samp Server /Stats Problem - Cezar98 - 30.06.2018

format(eString, 1500, "%s{FF9900}Killer statistics:\n\
{00FF00}Kills: {33FFFF}%d {00FF00}\n\
{00FF00}Killing Spree: {33FFFF}%d {00FF00}| Best Killing Spree: {33FFFF}%d\n\
{00FF00}Deaths: {33FFFF}%d\n\
{00FF00}Killer rank: {33FFFF}%s\n\n",
eString,
CosminInfo[liPlayer][Kills],
CosminInfo[liPlayer][KillingSpree],
CosminInfo[liPlayer][BestKillingSpree],
CosminInfo[liPlayer][Deaths],
CosminInfo[liPlayer][KillerRank]);


Re: Samp Server /Stats Problem - Calisthenics - 30.06.2018

The code above is OK. You probably did the same mistake when a player registers as in UPDATE query in your first post. Can you post the INSERT query?


Re: Samp Server /Stats Problem - Cezar98 - 30.06.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
The code above is OK. You probably did the same mistake when a player registers as in UPDATE query in your first post. Can you post the INSERT query?
format(rQuery, 4096, "INSERT INTO `Accounts` (`ID`, `Name`, `Password`, `SPassword`, `IP`, `E-Mail`, `LoggedIn`, `RegisterDate`, `LastOn`, `Level`, `VIP`, `Cash`, `Score`, `Coins`, \
`Headshots`, `Kills`, `Deaths`, `Hours`, `Minutes`, `Seconds`, `BestKillings`, `House`, `Property`, \
`Description1`, `Description2`, `Description3`, `Positive`, `Negative`,");
//------------------------------------------------------------------
format(rQuery, 4096, "%s `Kicks`, `Bans`, `Jails`, `Warns`, `ClearChats`, `ReactionTest`, `MathTest`, `Mutes`, `Jailed`, `Muted`, \
`RaceScore`, `StuntScore`, `DriftScore`, `GangID`, `GangRank`, `GangSkin`, `GangKills`, `GangDeaths`, `GangWarns`, `GangCaptures`, `GangPoints`, \
`LottoNumber`, `C4`, `StatsNote`, `VIPTime`, `BossSkin`, `TempVIP`, `AdmWarns`, `VIPWarns`, `KickW`, `ClanRank`, `ClanID`, `ClanName`)", rQuery);
//------------------------------------------------------------------
format(rQuery, 4096, "%s VALUES (0, '%s', '%s', '%s', '%s', 'Susan', '1', '%02d/%02d/%02d', '%02d/%02d/%02d', \
'0', '0', '25000', '100', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0','0', \
' ', ' ', ' ', '0', '0', \
'0', '0', '0', '0', '0', '0', '0', '0', '0', \
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', \
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'None')", rQuery, PlayerName(playerid), rPassword, CosminInfo[playerid][SPassword], GetPlayerIPEx(playerid), liDay, liMonth, liYear, liDay, liMonth, liYear);
//------------------------------------------------------------------
mysql_tquery(DB_Connect, rQuery, "OnAccountCreated", "i", playerid);


Re: Samp Server /Stats Problem - Calisthenics - 30.06.2018

The problem is not in INSERT query.

However a suggestion, use default values in mysql table. This way, you will not have to use so many '0' in your code and the query will be a lot smaller. Only strings require apostrophes around, not integers or floating-point numbers. Grave accent symbol is used if a column/table name has the same name as a SQL keyword to avoid conflicts, they are not required either for your case.

Anyway, we will fix the UPDATE query which is faulty. Take a look here:
pawn Код:
Headshots` = '%s', `Kills` = '%s', `Deaths` = '%s',
These are not strings, change to %d specifier. Change all of them.

One more important thing: update data when they change.
Level, skin etc can be updated when they change via commands/dialogs
kicks, bans etc can be increased when admins take action against the said player


Re: Samp Server /Stats Problem - Cezar98 - 30.06.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
The problem is not in INSERT query.

However a suggestion, use default values in mysql table. This way, you will not have to use so many '0' in your code and the query will be a lot smaller. Only strings require apostrophes around, not integers or floating-point numbers. Grave accent symbol is used if a column/table name has the same name as a SQL keyword to avoid conflicts, they are not required either for your case.

Anyway, we will fix the UPDATE query which is faulty. Take a look here:
pawn Код:
Headshots` = '%s', `Kills` = '%s', `Deaths` = '%s',
These are not strings, change to %d specifier. Change all of them.

One more important thing: update data when they change.
Level, skin etc can be updated when they change via commands/dialogs
kicks, bans etc can be increased when admins take action against the said player
I have setted default values and don't work


Re: Samp Server /Stats Problem - Verc - 30.06.2018

What do you mean? Have you change the query?