mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-11-22 10:12:20 +00:00
По какой-то причине ILuaModuleManager10::GetResourceName кладёт сервер. Используется альтернативный вариант получения имени ресурса.
This commit is contained in:
parent
7bc8f524b7
commit
b0cc1c5fd1
@ -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();
|
||||||
|
|
||||||
|
@ -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 )
|
||||||
|
Loading…
Reference in New Issue
Block a user