15.07.2018, 19:34
Hello everyone,
I am following BlueGs example on using MySQL: https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn
I can't wrap my head around the MySQL race solution he has to the problem:
(lines: 234-236)
player A connects -> SELECT query is fired -> this query takes very long
while the query is still processing, player A with playerid 2 disconnects
player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player
He goes on to say the solution to this is:
(lines 239-242)
we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
we also pass the current value of the connection count to our OnPlayerDataLoaded callback
then we check if current connection count is the same as connection count we passed to the callback
if yes, everything is okay, if not, we just kick the player
I don't understand how this is going to stop the problem (I know it is a solution, but I don't understand it.).
I would really appreciate it if someone could put this in other words.
Thanks in advance!
I am following BlueGs example on using MySQL: https://github.com/pBlueG/SA-MP-MySQ...stem-cache.pwn
I can't wrap my head around the MySQL race solution he has to the problem:
(lines: 234-236)
player A connects -> SELECT query is fired -> this query takes very long
while the query is still processing, player A with playerid 2 disconnects
player B joins now with playerid 2 -> our laggy SELECT query is finally finished, but for the wrong player
He goes on to say the solution to this is:
(lines 239-242)
we create a connection count for each playerid and increase it everytime the playerid connects or disconnects
we also pass the current value of the connection count to our OnPlayerDataLoaded callback
then we check if current connection count is the same as connection count we passed to the callback
if yes, everything is okay, if not, we just kick the player
I don't understand how this is going to stop the problem (I know it is a solution, but I don't understand it.).
I would really appreciate it if someone could put this in other words.
Thanks in advance!