Not saving stats.
#1

Hello, so I have a problem that if I kick or ban anyone it doesn't save stats, and I set up a timer that if you won't time your password for 30 seconds you will get kicked and when you do stats get deleted.

Edit: I forgat to mention that if I type /q or exit the game normaly it will save the stats.

this is my code at "OnPlayerDisconnect"

Код:
    new query[193];
    mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pAdmin`=%d, `pWarns`=%d, `pScore`=%d, `pMoney`=%d, `pSeconds`=%d, `pMinutes`=%d, `pHours`=%d WHERE `user` = '%e'", pInfo[playerid][pAdmin], pInfo[playerid][pWarns], GetPlayerScore(playerid), GetPlayerMoney(playerid), pInfo[playerid][pSeconds], pInfo[playerid][pMinutes], pInfo[playerid][pHours], Name[playerid]);
    mysql_tquery(mysql, query, "", "");

	mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pKills`=%d, `pDeaths`=%d, `pVehicle1`=%d, `pVehicle2`=%d, `pVehicle3`=%d, `pVehicle1Model`=%d, `pVehicle2Model`=%d, `pVehicle3Model`=%d WHERE `user` = '%e'", pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pVehicle1], pInfo[playerid][pVehicle2], pInfo[playerid][pVehicle3], pInfo[playerid][pVehicle1Model], pInfo[playerid][pVehicle2Model], pInfo[playerid][pVehicle3Model], Name[playerid]);
    mysql_tquery(mysql, query, "", "");

	mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pEvade`=%d, `pNeon`=%d, `pText`=%d, `pRam`=%d, `pVip`=%d WHERE `user` = '%e'", pInfo[playerid][pEvade], pInfo[playerid][pNeon], pInfo[playerid][pText], pInfo[playerid][pRam], pInfo[playerid][pVip], Name[playerid]);
    mysql_tquery(mysql, query, "", "");
Reply
#2

Show us OnPlayerDisconnect, the entire thing...
Reply
#3

Add a IsPlayerLoggedIn variable and change it to 1 when a player logs in. Check if IsPlayerLoggedIn variable is 1 on OnPlayerDisconnect and if it is 1, save the stats. If it is 0, skip the mentioned player. Also don't forget to add IsPlayerLoggedIn[playerid] = 0; when a player disconnects to avoid bugs.
Reply
#4

Rufio i've done what you said, and it didn't work, this is the code i made.

Edit: But it still saves my account how doesn't it save all of the stats like if im admin or something?

new variable
Код:
new IsPlayerLoggedIn[MAX_PLAYERS];
At "OnPlayerDisconnect"

Код:
	if(IsPlayerLoggedIn[playerid] == 1)
	{
	    new query[193];
	    mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pAdmin`=%d, `pWarns`=%d, `pScore`=%d, `pMoney`=%d, `pSeconds`=%d, `pMinutes`=%d, `pHours`=%d WHERE `user` = '%e'", pInfo[playerid][pAdmin], pInfo[playerid][pWarns], GetPlayerScore(playerid), GetPlayerMoney(playerid), pInfo[playerid][pSeconds], pInfo[playerid][pMinutes], pInfo[playerid][pHours], Name[playerid]);
	    mysql_tquery(mysql, query, "", "");

		mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pKills`=%d, `pDeaths`=%d, `pVehicle1`=%d, `pVehicle2`=%d, `pVehicle3`=%d, `pVehicle1Model`=%d, `pVehicle2Model`=%d, `pVehicle3Model`=%d WHERE `user` = '%e'", pInfo[playerid][pKills], pInfo[playerid][pDeaths], pInfo[playerid][pVehicle1], pInfo[playerid][pVehicle2], pInfo[playerid][pVehicle3], pInfo[playerid][pVehicle1Model], pInfo[playerid][pVehicle2Model], pInfo[playerid][pVehicle3Model], Name[playerid]);
	    mysql_tquery(mysql, query, "", "");

		mysql_format(mysql, query, sizeof(query), "UPDATE `"PlayerTable"` SET `pEvade`=%d, `pNeon`=%d, `pText`=%d, `pRam`=%d, `pVip`=%d WHERE `user` = '%e'", pInfo[playerid][pEvade], pInfo[playerid][pNeon], pInfo[playerid][pText], pInfo[playerid][pRam], pInfo[playerid][pVip], Name[playerid]);
	    mysql_tquery(mysql, query, "", "");
	}
At "OnPlayerConnect"
Код:
IsPlayerLoggedIn[playerid] = 1;
And i've added IsPlayerLoggedIn[playerid] = 0; at on player disconnect
Reply
#5

Why would you add IsPlayerLoggedIn[playerid] = 1; to OnPlayerConnect? The player wouldn't be logged in as soon as they connect, put it under your logging in dialog. Delete it from OnPlayerConnect
Reply
#6

Because I set up a timer that if he won't login it will kick him after 30 seconds. + I banned my self and it didn't work.
Reply
#7

Well, did you do it exactly like I said? It doesn't matter if you set up a timer to kick the player, it is a simple variable which determines if the player is logged in or not, setting it to 1 on OnPlayerConnect kills the entire system because it tells the system that a player has logged in AS SOON AS they connected to the server.

And as to your banning problem, are you sure you have set their pBanned variable to 1 upon banning?
Reply
#8

I did what you have said, Let me check if it works.
Reply
#9

No it doesn't work. I banned my self and it didn't save my stats after I logged in.

Edit: if I ban my self so when it kicks me doesn't it suppost to be like I life the server? and do it without any problems?
Reply
#10

Quote:
Originally Posted by rambalili2
Посмотреть сообщение
No it doesn't work. I banned my self and it didn't save my stats after I logged in.
What stats does it not save? Just the banning variable or all of them?

Also, do you have a callback to save a player's account i.e. SavePlayerAccount(playerid); ?
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)