По какой-то причине ILuaModuleManager10::GetResourceName кладёт сервер. Используется альтернативный вариант получения имени ресурса.

This commit is contained in:
Kernell 2015-11-28 04:45:49 +03:00
parent 7bc8f524b7
commit b0cc1c5fd1
2 changed files with 121 additions and 113 deletions

View File

@ -17,14 +17,23 @@ int CFunctions::monoInit( lua_State *pLuaVM )
{ {
if( pLuaVM ) if( pLuaVM )
{ {
CResource *pResource; CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
if( !( pResource = g_pResourceManager->GetFromList( pLuaVM ) ) ) if( pResource == nullptr )
{ {
pResource = g_pResourceManager->Create( pLuaVM ); //if( g_pModuleManager->GetResourceName( luaVM, strName ) )
CLuaArgument pLuaArgument( pLuaVM, -1 );
string strName = pLuaArgument.GetString();
if( !strName.empty() )
{
pResource = g_pResourceManager->Create( pLuaVM, strName );
}
} }
if( pResource ) if( pResource != nullptr )
{ {
pResource->Init(); pResource->Init();

View File

@ -25,19 +25,18 @@ MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, ch
return true; return true;
} }
MTAEXPORT void RegisterFunctions( lua_State *pLuaVM ) MTAEXPORT void RegisterFunctions( lua_State *pLuaVM )
{ {
if( g_pModuleManager && pLuaVM && g_pResourceManager ) if( g_pModuleManager && pLuaVM && g_pResourceManager )
{ {
if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) ) if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) )
{ {
luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" ); //luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" );
luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, function( res ) monoInit( getResourceName( res ) ) end )" );
} }
} }
} }
MTAEXPORT bool DoPulse( void ) MTAEXPORT bool DoPulse( void )
{ {
if( g_pResourceManager ) if( g_pResourceManager )