Skip to content

Commit abadfc0

Browse files
committed
Don't require Unload export from SA-MP plugins
1 parent cb4fce0 commit abadfc0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

amx-deps/src/CFunctions.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ AMX *suspendedAMX = NULL;
6666

6767
// amxLoadPlugin(pluginName)
6868
int CFunctions::amxLoadPlugin(lua_State *luaVM) {
69-
static const char *requiredExports[] = { "Load", "Unload", "Supports", 0 };
69+
static const char *requiredExports[] = { "Load", "Supports", 0 };
7070

7171
const char *pluginName = luaL_checkstring(luaVM, 1);
7272
if(!pluginName || loadedPlugins.find(pluginName) != loadedPlugins.end() || !isSafePath(pluginName)) {
@@ -218,7 +218,7 @@ int CFunctions::amxLoad(lua_State *luaVM) {
218218
lua_getfield(luaVM, LUA_REGISTRYINDEX, "amx");
219219
lua_getfield(luaVM, -1, resName);
220220
if(lua_isnil(luaVM, -1)) {
221-
lua_newtable(luaVM);
221+
lua_newtable(luaVM);
222222
lua_setfield(luaVM, -3, resName);
223223
}
224224

@@ -403,7 +403,10 @@ int CFunctions::amxUnload(lua_State *luaVM) {
403403
// amxUnloadAllPlugins()
404404
int CFunctions::amxUnloadAllPlugins(lua_State *luaVM) {
405405
for (map< string, SampPlugin* >::iterator it = loadedPlugins.begin(); it != loadedPlugins.end(); it++) {
406-
it->second->Unload();
406+
Unload_t* Unload = it->second->Unload;
407+
if (Unload) {
408+
Unload();
409+
}
407410
freeLib(it->second->pPluginPointer);
408411
delete it->second;
409412
}

0 commit comments

Comments
 (0)