|
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
|
05-28-2017
, 15:43
Re: Chat Manager [Admin Prefix & Color Chat]
|
#7
|
Spoiler
PHP Code:
SortPluginsFile() { new TempFileName[] = "temp_plugins.ini" new HandleConfigsDir[128], TempFilePath[128], PluginToSearchFor[32] get_configsdir(HandleConfigsDir, charsmax(HandleConfigsDir)) get_plugin(-1, PluginToSearchFor, charsmax(PluginToSearchFor))
formatex(TempFilePath, charsmax(TempFilePath), "%s/%s", HandleConfigsDir, TempFileName) add(HandleConfigsDir, charsmax(HandleConfigsDir), "/plugins.ini") new FilePointer = fopen(HandleConfigsDir, "rt") new TempPointer = fopen(TempFilePath, "wt") new bool:FoundSomething
if(FilePointer) { new FileData[128] while(!feof(FilePointer)) { fgets(FilePointer, FileData, charsmax(FileData)) trim(FileData) if(contain(FileData, PluginToSearchFor) != -1) { FoundSomething = true continue } fputs(TempPointer, FileData) } fclose(FilePointer) fclose(TempPointer) if(FoundSomething) { delete_file(HandleConfigsDir) rename_file(TempFilePath, HandleConfigsDir, true) FilePointer = fopen(HandleConfigsDir, "a") if(FilePointer) { fputs(FilePointer, PluginToSearchFor) fclose(FilePointer) server_cmd("restart") } } else { delete_file(TempFilePath) } } }
Should always make sure that the current plugin is always the last in plugins.ini
I did not test it, and it may not be the best implementation, but I did it only for fun and in a rush. Use something like this if you want.
__________________
Last edited by HamletEagle; 05-28-2017 at 15:44.
|
|
|
|