SA-MP Forums Archive
Server crashes when kicking a player inside OnPlayerStateChange - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: Server crashes when kicking a player inside OnPlayerStateChange (/showthread.php?tid=662952)



Server crashes when kicking a player inside OnPlayerStateChange - Graber - 16.01.2019

When using Kick(playerid) inside OnPlayerStateChange, and the newstate is PLAYER_STATE_DRIVER, the server crashes:

0.3.DL Windows:
Code:
[22:11:08] [debug] Server crashed due to an unknown error
[22:11:08] [debug] Native backtrace:
[22:11:08] [debug] #0 004874d1 in ?? () in samp-server.exe
[22:11:08] [debug] #1 004950b3 in ?? () in samp-server.exe
[22:11:08] [debug] #2 777fb8d0 in ?? () in C:\WINDOWS\SYSTEM32\ntdll.dll
After making some internal debugging, it seems this happens because the server tries to use the player's pointer after calling the callback, but the pointed memory was already freed because the player was kicked.


Re: Server crashes when kicking a player inside OnPlayerStateChange - rorrobryan - 17.01.2019

It may be that you save the data wrong or you need to add a folder of logs in scriptfiles


Re: Server crashes when kicking a player inside OnPlayerStateChange - Kaliber - 18.01.2019

You have to use a small timer, to delay the kick