"/q" not saving data
#1

I use this login/registration system: https://sampforum.blast.hk/showthread.php?tid=574714

I noticed when i'm using /q, it does not saves character data, ex: Last position

Anybody can help me with this?
Reply
#2

Check callback OnPlayerDisconnect

Quote:

public OnPlayerDisconnect(playerid, reason)
{
new
query[128],
Floatos[4];

GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);

mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f WHERE `ID` = %d",
GetPlayerMoney(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]);
mysql_tquery(mysql, query, "", "");

return true;
}

Reply
#3

Do you have a saving part on OnPlayerDisconnect?

Edit: Eloy replied faster than me
Reply
#4

GetPlayer_ functions do NOT work reliably in OnPlayerDisconnect because the client is already disconnected at that point.
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
GetPlayer_ functions do NOT work reliably in OnPlayerDisconnect because the client is already disconnected at that point.
Hmmm.. How can I able to do a workaround fix for it?
Reply
#6

Just try it, because I use the GetPlayer_ functions under OnPlayerDisconnect() and I've never witnessed problems nor bugs til now.
Reply
#7

I do have a call function for OnPlayerDisconnect. But as vince said, maybe the force quit doesn't connected to GetPlayer_ functions.
Reply
#8

Create separate variable for storing money, score etc. Increment/decrement their value whenever the the change is needed. Now use this variable in OnPlayerDisconnect(). Do not forget to reset them after saving it in OnPlayerDisconnect().

Storing money in variable also helps to detect money hack. As if player uses a money cheat GetPlayerMoney will return then money value at from client side which could be changed with help of a hack but the value stored in variable you made in script won't change as it is server sided.
Reply
#9

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
Create separate variable for storing money, score etc. Increment/decrement their value whenever the the change is needed. Now use this variable in OnPlayerDisconnect(). Do not forget to reset them after saving it in OnPlayerDisconnect().

Storing money in variable also helps to detect money hack. As if player uses a money cheat GetPlayerMoney will return then money value at from client side which could be changed with help of a hack but the value stored in variable you made in script won't change as it is server sided.
Can you give me a example of a code for it?
Reply
#10

Search in SA-MP forums for existing threads before posting
Check OnPlayerDisconnect
Also, a similar thread : https://sampforum.blast.hk/showthread.php?tid=512511
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)