Occasional server crash

Started by Yyg, Jul 20, 2020, 04:21 PM

Previous topic - Next topic

Yyg

:))Sorry for my bad English, but I ran into some problems

I'm writing a server and I didn't encounter any problems during the game, but when I try to log out of the server (or reconnect), occasionally the server crashes

This situation does not happen every time, the specific process:
[noae][noae][noae]1.I try ESC-RECONNNECT
2.Leave the server normally, the server no error print

Immediately afterwards, the client connects to the server immediately, and successfully connects, but still stays in the loading and loading server resource window, the server will crash after a few seconds
[/noae][/noae][/noae]

When this happens, the server does not have any errors, and even onPlayerJoin will not be called, but the client receives the Loading server info...

The only content output by the server may be "player login failed"

But I need to repeat, I have tested it many times, this situation does not happen often, it makes me feel random
I have set try catch in onPlayerPart, but there is still no error, the server will crash without any error

This onPlayerPart Code:
[noae][noae][noae]function onPlayerPart(player, reason)
{
//try{
if(player == null) return;
else if(player.ID <= -1) return;
else if(status[player.ID] == null) return;

if(status[player.ID].LoggedIn)
{
SaveStats(player);
}

        //This some Unique Player Timer
if(status[player.ID].WaitAccountTimer != null) status[player.ID].WaitAccountTimer.Delete();
if(status[player.ID].CameraFuncTimer != null) status[player.ID].CameraFuncTimer.Delete();
if(status[player.ID].UniqueVehicle != null) status[player.ID].UniqueVehicle.Delete();
if(status[player.ID].TempVehicle != null) status[player.ID].TempVehicle.Delete();

for(local i=0;i<status[player.ID].UniqueMarkers.len();i++)
{
if(status[player.ID].UniqueMarkers[i] != null) DestroyMarker(status[player.ID].UniqueMarkers[i]);
}

for(local i=0;i<status[player.ID].DropWeaponPickups.len();i++)
{
if(status[player.ID].DropWeaponPickups[i] != null) status[player.ID].DropWeaponPickups[i].Remove();
}

for(local i=0;i<status[player.ID].DropPickups.len();i++)
{
if(status[player.ID].DropPickups[i] != null) status[player.ID].DropPickups[i].Remove();
}

        //This Timer too, but no catch any error
try{
for(local i=0;i<status[player.ID].CTimers.len();i++)
{
if(status[player.ID].CTimers[i] != null) status[player.ID].CTimers[i].Delete();
}
}catch(e)
{
CPrint("PlayerPart CTimer err: " + e.tostring());
}
status[player.ID].CTimers.clear();

status[player.ID] = null;
/*}catch(ex)
{
CPrint("ERROR " + ex.tostring());
}*/
}

function SaveStats(player)
{
if(!status[player.ID].LoggedIn) return;

SaveAllWeapons(player);
SavePlayerPosition(player);

local _readySkin = player.Skin;
        //I know these codes are not standardized, but I don't think it will crash
local q = QuerySQL(db,
format(@"UPDATE [Accounts] SET
[UID]='%s',
[IP]='%s',
[Level]='%s',
[Exp]='%s',
[Cash]='%s',
[Bank]='%s',
[Kills]='%s',
[Deaths]='%s',
[Bubble]='%s',
[Skin]='%s',
[Health]='%s',
[Armour]='%s',
[WantedLevel]='%s',
[Team]='%s',
[Stock]='%s',
[_BubbleList]='%s',
[_SkinList]='%s',
[_WeaponList]='%s',
[_PhoneConfig]='%s',
[_HistoryCash]='%s',
[_LastConnectTime]='%s',
[AdminLevel]='%s'
WHERE [Name]='%s';",

status[ player.ID ].UID.tostring(),
status[ player.ID ].IP.tostring(),
status[ player.ID ].Level.tostring(),
status[ player.ID ].Exp.tostring(),
status[ player.ID ].Cash.tostring(),
status[ player.ID ].Bank.tostring(),
status[ player.ID ].Kills.tostring(),
status[ player.ID ].Deaths.tostring(),
status[ player.ID ].Bubble.tostring(),
_readySkin.tostring(),
status[ player.ID ].Health.tostring(),
status[ player.ID ].Armour.tostring(),
status[ player.ID ].WantedLevel.tostring(),
status[ player.ID ].Team.tostring(),
status[ player.ID ].Stock.tostring(),
status[ player.ID ]._BubbleList.tostring(),
status[ player.ID ]._SkinList.tostring(),
status[ player.ID ]._WeaponList.tostring(),
status[ player.ID ]._PhoneConfig.tostring(),
status[ player.ID ]._HistoryCash.tostring(),
g_ServerLocalTime.tostring(),
status[player.ID].AdminLevel.tostring(),
player.Name.tolower()
)
);
FreeSQLQuery( q );
}

function SaveAllWeapons( player )
{
if(!status[player.ID].LoggedIn) return;

local sql = "";
local isFirst = true;

for(local i = 0; i <= 8; i++ )
{
local wep = player.GetWeaponAtSlot( i ),
  ammo = player.GetAmmoAtSlot( i );
if( wep != 0 )
{
sql += wep + "," + ammo + "|";
}
}

status[player.ID].Weapon = sql;
UpdatePlayerDatabase(player, "Weapon", sql);
}

function SavePlayerPosition( player, pos = null, angle = null )
{
if(player == null || player.Pos == null) return;
else if(!status[player.ID].LoggedIn) return;

if( pos == null )
{
        status[player.ID].Position = player.Pos.x + "," + player.Pos.y + "," + player.Pos.z + "|" + player.Angle;
}else{
status[player.ID].Position = pos.x + "," + pos.y + "," + pos.z + "|" + angle;
}

UpdatePlayerDatabase(player, "Position", status[player.ID].Position);
}
[/noae][/noae][/noae]

I have also seen people who had the same problem in 2015 in the forum, but he did not solve it

After my test, I think this problem may be related to the SQlite plug-in or VCMP server. Can someone help me?

Thank you

Error Screenshot:

Until here, the server started to crash


Here, the exit print is output normally without any error
But this time did not receive any onPlayerJoin

Razor.

I think this crash is related to the client side.

Yyg

Maybe yes, but any good suggestions? Or what should I do?

Yyg

There may be a similar situation in the forum, but I am not sure if it is for the same reason
https://forum.vc-mp.org/?topic=2396.msg17715#msg17715

Razor.

Add // to all functions (one function at a time) of onPlayerPart and onPlayerJoin and test one by one until you find the problem.

Yyg

Quote from: Razor. on Jul 22, 2020, 05:20 PMAdd // to all functions (one function at a time) of onPlayerPart and onPlayerJoin and test one by one until you find the problem.

Ok thank you! this is obviously a very safe method, but because this problem does not appear every time, maybe I will test it for a long time xd

Xmair

From what I have experienced, deleting or stopping timers cause crashes.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

umar4911

Might be some queries or a function on the player's exit which are taking time causing the original player instance not being removed from the server. Just guessing,
I am gamer, programmer and hacker. Try to find me!
xD

Yyg

Thank you everyone for your help. I tried to remove the socket plug-in. I haven't found this problem for the time being. Maybe this is the main reason.

Locked