Informacje dla Developerów:
/**
* Adds your plugin to the updater. The URL will be updated if
* your plugin was previously added.
*
* @param url URL to your plugin's update file.
* @noreturn
*/
native Updater_AddPlugin(const String:url[]);
/**
* Removes your plugin from the updater. This does not need to
* be called during OnPluginEnd.
*
* @noreturn
*/
native Updater_RemovePlugin();
/**
* Forces your plugin to be checked for updates. The behaviour
* of the update is dependant on the server's configuration.
*
* @return True if an update was triggered. False otherwise.
* @error Plugin not found in updater.
*/
native bool:Updater_ForceUpdate();
/**
* Called when your plugin is about to be checked for updates.
*
* @return Plugin_Handled to prevent checking, Plugin_Continue to allow it.
*/
forward Action:Updater_OnPluginChecking();
/**
* Called when your plugin is about to begin downloading an available update.
*
* @return Plugin_Handled to prevent downloading, Plugin_Continue to allow it.
*/
forward Action:Updater_OnPluginDownloading();
/**
* Called when your plugin's update files have been fully downloaded
* and are about to write to their proper location. This should be used
* to free read-only resources that require write access for your update.
*
* @note OnPluginUpdated will be called later during the same frame.
*
* @noreturn
*/
forward Updater_OnPluginUpdating();
/**
* Called when your plugin's update has been completed. It is safe
* to reload your plugin at this time.
*
* @noreturn
*/
forward Updater_OnPluginUpdated();
/**
* @brief Reloads a plugin.
*
* @param plugin Plugin Handle (INVALID_HANDLE uses the calling plugin).
* @noreturn
*/
stock ReloadPlugin(Handle:plugin=INVALID_HANDLE);
Kiedy testujecie update w swoim pluginie, rekomendowane jest przetestowanie ponownie z debugiem w Updater.smx .
To powinno zalogować szczegóły informacje o pobierania do pliku Updater_Debug.log w przypadku, gdy przypadkowo użyjesz nieprawidłowych ścieżek lub URL'y
/* Linia 25: updater.sp */
#define DEBUG // To włącza logowanie. Użyteczne dla developerów testujących aktualizowanie pluginów.
Przykładowy Plugin:
#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <updater>
#define UPDATE_URL "http://website.com/myplugin/updatefile.txt"
public OnPluginStart()
{
if (LibraryExists("updater"))
{
Updater_AddPlugin(UPDATE_URL)
}
}
public OnLibraryAdded(const String:name[])
{
if (StrEqual(name, "updater"))
{
Updater_AddPlugin(UPDATE_URL)
}
}
Teraz przjrzyjmy się jak tworzyć UPDATE_URL (jak na przykładzie updatefile.txt ) ...
Wygląd Pliku AktualizacjiSimple Update - więkrzość pluginów bedzie używać tego.
"Updater"
{
"Information"
{
"Version"
{
"Latest" "1.0.1"
}
"Notes" "More info @ www.sourcemod.net. Changes in 1.0.1:"
"Notes" "Added new Batman model"
"Notes" "Minor code changes"
}
"Files"
{
"Plugin" "Path_SM/plugins/myplugin.smx"
"Plugin" "Path_SM/translations/myplugin.phrases.txt"
"Plugin" "Path_SM/translations/ru/myplugin.phrases.txt"
"Plugin" "Path_Mod/models/characters/batman.mdl"
"Plugin" "Path_Mod/materials/models/characters/batman.vmt"
"Source" "Path_SM/scripting/myplugin.sp"
}
}
Patch Update - Użyteczny dla dużych pluginów do uniknięcia ściągnia wszystkich plików, gdy tylko mamy mało zmian. Łatki (Patch) będą używane jeśli "Previous" (poprzednia) wersja plugina dopasuje się z serwerową obecną działającą wersja.
"Updater"
{
"Information"
{
"Version"
{
"Latest" "1.0.1"
"Previous" "1.0.0"
}
"Notes" "More info @ www.sourcemod.net. Changes in 1.0.1:"
"Notes" "Added Russian phrases"
"Notes" "Minor code changes"
}
"Files"
{
"Patch"
{
"Plugin" "Path_SM/plugins/myplugin.smx"
"Plugin" "Path_SM/translations/ru/myplugin.phrases.txt"
"Source" "Path_SM/scripting/myplugin.sp"
}
"Plugin" "Path_SM/plugins/myplugin.smx"
"Plugin" "Path_SM/translations/myplugin.phrases.txt"
"Plugin" "Path_SM/translations/ru/myplugin.phrases.txt"
"Plugin" "Path_Mod/models/characters/batman.mdl"
"Plugin" "Path_Mod/materials/models/characters/batman.vmt"
"Source" "Path_SM/scripting/myplugin.sp"
}
}
Wszystkie ścieżki internetowe są względe do aktualizacji plików twoich pluginów (UPDATE_URL w tym przypadku).
Użyte na powyższym przykładzie, URL'y do aktualizacji wyglądaja nastepująco:
UPDATE_URL = http://website.com/myplugin/updatefile.txt
http://website.com/myplugin/plugins/myplugin.smx
http://website.com/myplugin/translations/myplugin.phrases.txt
http://website.com/myplugin/translations/ru/myplugin.phrases.txt
http://website.com/myplugin/models/characters/batman.mdl
http://website.com/myplugin/materials/models/characters/batman.vmt
http://website.com/myplugin/scripting/myplugin.sp
Finalna NotkaPowinieneś tylko przeładowywać swój plugin ręcznie, jeśli on umie późno załadować uchwyt sytuacji (eventów/hooków)
W przeciwnym razie on przeładuje się automatycznie podczas następnej zmiany mapy - jest to bezpieczne