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
@ -1,36 +1,45 @@
|
|||||||
/*********************************************************
|
/*********************************************************
|
||||||
*
|
*
|
||||||
* Copyright © 2013, Innovation Roleplay Engine.
|
* Copyright © 2013, Innovation Roleplay Engine.
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
* with or without modification,
|
* with or without modification,
|
||||||
* is permitted only for authors.
|
* is permitted only for authors.
|
||||||
*
|
*
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
|
||||||
#include "CFunctions.h"
|
#include "CFunctions.h"
|
||||||
#include "extra/CLuaArguments.h"
|
#include "extra/CLuaArguments.h"
|
||||||
|
|
||||||
int CFunctions::monoInit( lua_State *pLuaVM )
|
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 );
|
||||||
if( pResource )
|
|
||||||
{
|
string strName = pLuaArgument.GetString();
|
||||||
pResource->Init();
|
|
||||||
|
if( !strName.empty() )
|
||||||
return 1;
|
{
|
||||||
}
|
pResource = g_pResourceManager->Create( pLuaVM, strName );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
|
if( pResource != nullptr )
|
||||||
|
{
|
||||||
|
pResource->Init();
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
@ -1,79 +1,78 @@
|
|||||||
/*********************************************************
|
/*********************************************************
|
||||||
*
|
*
|
||||||
* Copyright © 2013, Innovation Roleplay Engine.
|
* Copyright © 2013, Innovation Roleplay Engine.
|
||||||
*
|
*
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
* with or without modification,
|
* with or without modification,
|
||||||
* is permitted only for authors.
|
* is permitted only for authors.
|
||||||
*
|
*
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
|
||||||
#include "mta-mono.h"
|
#include "mta-mono.h"
|
||||||
|
|
||||||
MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion )
|
MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion )
|
||||||
{
|
{
|
||||||
g_pModuleManager = pManager;
|
g_pModuleManager = pManager;
|
||||||
g_pResourceManager = new CResourceManager();
|
g_pResourceManager = new CResourceManager();
|
||||||
|
|
||||||
strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH );
|
strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH );
|
||||||
strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH );
|
strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH );
|
||||||
|
|
||||||
(*fVersion) = MODULE_VERSION;
|
(*fVersion) = MODULE_VERSION;
|
||||||
|
|
||||||
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 )
|
{
|
||||||
{
|
g_pResourceManager->DoPulse();
|
||||||
g_pResourceManager->DoPulse();
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
MTAEXPORT bool ShutdownModule( void )
|
||||||
MTAEXPORT bool ShutdownModule( void )
|
{
|
||||||
{
|
if( g_pResourceManager )
|
||||||
if( g_pResourceManager )
|
{
|
||||||
{
|
delete g_pResourceManager;
|
||||||
delete g_pResourceManager;
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
||||||
MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
{
|
||||||
{
|
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
{
|
||||||
{
|
pResource->OnStopping();
|
||||||
pResource->OnStopping();
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
MTAEXPORT bool ResourceStopped( lua_State* luaVM )
|
||||||
MTAEXPORT bool ResourceStopped( lua_State* luaVM )
|
{
|
||||||
{
|
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
{
|
||||||
{
|
delete pResource;
|
||||||
delete pResource;
|
}
|
||||||
}
|
|
||||||
|
return true;
|
||||||
return true;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user