View Issue Details

IDProjectCategoryView StatusLast Update
0007427Multi Theft Auto : San AndreasServerpublic2013-06-05 11:28
ReporterKernellAssigned Toccw 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Platformx86_64OSCentOS 6.2, OpenSUSE 12.2, Win 7OS Version
Product Version 
Target Version1.4Fixed in Version1.4 
Summary0007427: onPlayerQuit not called on shutdown (was:Priority for onResourceStop does not work)
Description

For example, i have MySQL resource for manage MySQL queries and Gamemode resource.

When server shutting down, the MySQL resource stops earlier than Gamemode, which causes errors (ERROR: exports: Call to non-running server resource (CMySQL) [string "?"]) and does not save players, vehicles and etc.

Priority for Gamemode set to "high +10"

Steps To Reproduce

Gamemode resource:

local function void_stop()
outputDebugString( "Stopping gamemode: [ OK ]" );
end

addEventHandler( 'onResourceStop', resourceRoot, void_stop, true, "high" );

CMySQL:

local function void_stop()
outputDebugString( "Stopping CMySQL: [ OK ]" );
end

addEventHandler( 'onResourceStop', resourceRoot, void_stop );

server.log:

[2012-11-19 14:03:40] INFO: Stopping CMySQL: [ OK ]
[2012-11-19 14:03:40] INFO: Stopping Gamemode: [ OK ]
[2012-11-19 14:03:40] ERROR: exports: Call to non-running server resource (CMySQL) [string "?"]

TagsNo tags attached.

Activities

sbx320

2012-11-21 19:23

administrator   ~~0017869

The priority only sets the order of execution for the eventhandlers for one single event. In your example onResourceStop is called twice (Gamemode, CMySQL). This order of resources being stopped is not affected by eventhandler priority.

To solve your issue you can just check for the CMySQL resource being stopped like the following:

addEventHandler("onResourceStop", root,
function(resource)
if getResourceName(resource) == "CMySQL" or resource == getThisResource() then
-- Either CMySQL or this resource is going to stop
end
end
, true, "high+100")

Kernell

2012-11-23 16:56

reporter   ~~0017871

What good of your check?

When server shutting down, the MySQL resource stops earlier than Gamemode, which causes errors (ERROR: exports: Call to non-running server resource (CMySQL) [string "?"]) and DOES NOT SAVE PLAYERS, VEHICLES AND ETC.

You understand that from this data is lost?

Moreover, CMySQL resource added to "include" in a meta.xml Gamemode, but the resource is still CMySQL stops first!

ccw

2012-12-01 01:33

administrator   ~~0017880

Kernell, I think sbx320 is suggesting to put his addEventHandler code inside your Gamemode:

addEventHandler("onResourceStop", root,
function(resource)
if getResourceName(resource) == "CMySQL" or resource == getThisResource() then
-- Save data here as it should always occur before CMySQL is stopped
end
end
, true, "high+100")

arranTuna

2013-06-05 00:09

manager   ~~0018644

You should make a command that kicks all players before shutting the server down.

A safe shutdown could kick all the players first so that whatever needs saving is saved and then only really shut the server down when everyone has been kicked.

ccw

2013-06-05 07:01

administrator   ~~0018646

Good idea.
Fixed in http://code.google.com/p/mtasa-blue/source/detail?r=5493

Issue History

Date Modified Username Field Change