![]() |
|
[Request] Plugin version checker - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html) +--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html) +--- Thread: [Request] Plugin version checker (/Thread-Request-Plugin-version-checker.html) Pages:
1
2
|
Plugin version checker - raminr63 - 10-29-2012 Hi Guys to improve my plugin performance i need a simple code to add in to my plugin to check plugin version from my site and if new version of plugin is released every 3 minute in game say "New version of Plugin is released pleas See our site". I have idea to checking new version 1)may have sipmle way such as if in link "www.mysite.com/ver.txt the valu 1 = new version or if valu 0 no new version and no need to update. 2)or by cheking MD5 3)or... Thank you. RE: Plugin version checker - zxz0O0 - 10-29-2012 Store MD5 (or SHA1) in a www.mysite.com/ver.txt RE: Plugin version checker - OzonE - 10-30-2012 I Think this will help you this is the one when i tried to do this on God Plugin but Since i Dont have a Site So I Removed it from my code Code: public override void OnServerLoad
try
{
WebClient up = new WebClient();
string download = up.DownloadString("http://www.mysite.com/update.txt");
string[] downloads = download.Split(',');
}
if downloads = "1"
ServerPrint("Update Is available")
//whatever else you wanna addInform me if this works or sth else. RE: Plugin version checker - zxz0O0 - 10-30-2012 The code is wrong anyway but checking for '1' in a text file doesn't make sense. Sure it will show 'There is an update' but after you updated it will show the message again because the text file still contains '1'. And then if you remove the '1' from the file, the people who haven't updated yet will never receive the update message. RE: Plugin version checker - OzonE - 10-30-2012 hmmm. true. but still fixable. i believe ramin can fix it, i dont have time for this. RE: Plugin version checker - JariZ - 10-30-2012 Use the version number. That's what I always do. if(currentversion != serverversion) launchUpdater() RE: Plugin version checker - archit - 11-03-2012 Uses System.Net and Sytem.Linq Code: private const decimal Version = 1.2m;
public overide void OnServerLoad()
{
WebClient version = new WebClient();
decimal CurrentVersion = decimal.Parse(up.DownloadString("http://www.mysite.com/update.txt"));
if(CurrentVersion!=Version)
{
Timer update = new Timer(int.Parse(GetServerCFG("myplugin","Update Notify","3000"));
update.Elapsed+=(sender,e)=>
{
if(GetSeverCFG("myplugin","UpdateNotifyAdminOnly","false")!="false"&&GetClients()!=null)
{
foreach(string AdminXUID in GetSeverCFG("myplugin","Admin_XUIDs","").Split(new char[]{',',';'}))
{
ServerClient Client;
if(TellClient(GetClients.Where(Client=>Client.XUID==AdminXUID).ToArray().Length!=0)
{
Client=GetClients.Where(Client=>Client.XUID==AdminXUID).ToArray()[0];
TellClient(Client.ClientNum,"myplugin:New version available!!");
}
}
}
else
ServerSay("myplugin:New version available!!", true);
ServerPrint("myplugin:New version available!!");
}
update.Enabled=true;
}
}RE: Plugin version checker - raminr63 - 11-03-2012 Hi @archit your code has many problem pleas recheck your code. thank you. RE: Plugin version checker - zxz0O0 - 11-04-2012 Linq is not included in NET 3.0 RE: Plugin version checker - archit - 11-04-2012 This should work Code: public override void OnServerLoad()
{
WebClient version = new WebClient();
decimal CurrentVersion = decimal.Parse(version.DownloadString("http://www.mysite.com/update.txt"));
if (CurrentVersion != Version)
{
Timer update = new Timer(int.Parse(GetServerCFG("myplugin", "Update Notify", "3000")));
update.Elapsed += (sender, e) =>
{
if (GetServerCFG("myplugin", "UpdateNotifyAdminOnly", "false") != "false" && GetClients() != null)
{
foreach (string AdminXUID in GetServerCFG("myplugin", "Admin_XUIDs", "").Split(new char[] { ',', ';' }))
{
ServerClient client;
if (GetClients().Where(Client => Client.XUID == AdminXUID).ToArray().Length != 0)
{
client = GetClients().Where(Client => Client.XUID == AdminXUID).ToArray()[0];
TellClient(client.ClientNum, "myplugin:New version available!!", true);
}
}
}
else
ServerSay("myplugin:New version available!!", true);
ServerPrint("myplugin:New version available!!");
};
update.Enabled = true;
} |