mirror of
https://github.com/ChronosX88/mta-mono.git
synced 2024-12-23 01:11:48 +00:00
По какой-то причине ILuaModuleManager10::GetResourceName кладёт сервер. Используется альтернативный вариант получения имени ресурса.
This commit is contained in:
parent
7bc8f524b7
commit
b0cc1c5fd1
@ -1,36 +1,45 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "CFunctions.h"
|
||||
#include "extra/CLuaArguments.h"
|
||||
|
||||
int CFunctions::monoInit( lua_State *pLuaVM )
|
||||
{
|
||||
if( pLuaVM )
|
||||
{
|
||||
CResource *pResource;
|
||||
|
||||
if( !( pResource = g_pResourceManager->GetFromList( pLuaVM ) ) )
|
||||
{
|
||||
pResource = g_pResourceManager->Create( pLuaVM );
|
||||
}
|
||||
|
||||
if( pResource )
|
||||
{
|
||||
pResource->Init();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "CFunctions.h"
|
||||
#include "extra/CLuaArguments.h"
|
||||
|
||||
int CFunctions::monoInit( lua_State *pLuaVM )
|
||||
{
|
||||
if( pLuaVM )
|
||||
{
|
||||
CResource *pResource = g_pResourceManager->GetFromList( pLuaVM );
|
||||
|
||||
if( pResource == nullptr )
|
||||
{
|
||||
//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 != nullptr )
|
||||
{
|
||||
pResource->Init();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,79 +1,78 @@
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "mta-mono.h"
|
||||
|
||||
MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion )
|
||||
{
|
||||
g_pModuleManager = pManager;
|
||||
g_pResourceManager = new CResourceManager();
|
||||
|
||||
strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH );
|
||||
strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH );
|
||||
|
||||
(*fVersion) = MODULE_VERSION;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
MTAEXPORT void RegisterFunctions( lua_State *pLuaVM )
|
||||
{
|
||||
if( g_pModuleManager && pLuaVM && g_pResourceManager )
|
||||
{
|
||||
if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) )
|
||||
{
|
||||
luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MTAEXPORT bool DoPulse( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
{
|
||||
g_pResourceManager->DoPulse();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ShutdownModule( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
{
|
||||
delete g_pResourceManager;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
{
|
||||
pResource->OnStopping();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ResourceStopped( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
{
|
||||
delete pResource;
|
||||
}
|
||||
|
||||
return true;
|
||||
/*********************************************************
|
||||
*
|
||||
* Copyright © 2013, Innovation Roleplay Engine.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification,
|
||||
* is permitted only for authors.
|
||||
*
|
||||
*********************************************************/
|
||||
|
||||
#include "mta-mono.h"
|
||||
|
||||
MTAEXPORT bool InitModule( ILuaModuleManager10 *pManager, char *szModuleName, char *szAuthor, float *fVersion )
|
||||
{
|
||||
g_pModuleManager = pManager;
|
||||
g_pResourceManager = new CResourceManager();
|
||||
|
||||
strncpy( szModuleName, MODULE_NAME, MAX_INFO_LENGTH );
|
||||
strncpy( szAuthor, MODULE_AUTHOR, MAX_INFO_LENGTH );
|
||||
|
||||
(*fVersion) = MODULE_VERSION;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT void RegisterFunctions( lua_State *pLuaVM )
|
||||
{
|
||||
if( g_pModuleManager && pLuaVM && g_pResourceManager )
|
||||
{
|
||||
if( g_pModuleManager->RegisterFunction( pLuaVM, "monoInit", CFunctions::monoInit ) )
|
||||
{
|
||||
//luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, monoInit )" );
|
||||
luaL_dostring( pLuaVM, "addEventHandler( 'onResourceStart', resourceRoot, function( res ) monoInit( getResourceName( res ) ) end )" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MTAEXPORT bool DoPulse( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
{
|
||||
g_pResourceManager->DoPulse();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ShutdownModule( void )
|
||||
{
|
||||
if( g_pResourceManager )
|
||||
{
|
||||
delete g_pResourceManager;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ResourceStopping( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
{
|
||||
pResource->OnStopping();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MTAEXPORT bool ResourceStopped( lua_State* luaVM )
|
||||
{
|
||||
if( CResource *pResource = g_pResourceManager->GetFromList( luaVM ) )
|
||||
{
|
||||
delete pResource;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue
Block a user