Difference between revisions of "Install mod from WHMCS"

From TCAdmin 2.0 Documentation
(Created page with "The following Iron python script will install a mod after the game server has been created. Create a variable named "ModToInstall". Configure WHMCS to send the mod id to be in...")
(No difference)

Revision as of 20:49, 30 June 2020

The following Iron python script will install a mod after the game server has been created. Create a variable named "ModToInstall". Configure WHMCS to send the mod id to be installed after creating the game server. Configure it for the game's after created event. The script and variable can be configured as global.


import clr;
import System;

if (not ThisService.Variables.HasValue("ModToInstall")) or ThisService.Variables["ModToInstall"] == "":
  Script.Exit()

clr.AddReference("TCAdmin.SDK");
clr.AddReference("TCAdmin.GameHosting.SDK");
clr.AddReference("TCAdmin.GameHosting.ModuleApi");
clr.AddReference("TCAdmin.TaskScheduler.SDK");

from System import String;
from TCAdmin.SDK.Misc import ObjectXml;
from TCAdmin.GameHosting.SDK.Automation import GameHostingModInstallInfo;
from TCAdmin.GameHosting.ModuleApi import ModuleDef;
from TCAdmin.TaskScheduler.SDK.Objects import TaskStep;

modinfo = GameHostingModInstallInfo();
GameHostingModInstallInfo.ServiceId.SetValue(modinfo, ThisService.ServiceId);
GameHostingModInstallInfo.ModId.SetValue(modinfo, int(ThisService.Variables["ModToInstall"]));
GameHostingModInstallInfo.Variables.SetValue(modinfo, String.Empty);

modstep = TaskStep();
modstep.TaskId = ThisTaskStep.Arguments.TaskId;
modstep.ModuleId = ModuleDef.ModuleId;
modstep.ProcessId = 8;
modstep.ServerId = ThisService.ServerId;
modstep.Name = "Install mod";
modstep.Arguments = ObjectXml.ObjectToXml(modinfo);
modstep.GenerateKey();
modstep.Save();
Retrieved from "https://help.tcadmin.com/index.php?title=Install_mod_from_WHMCS&oldid=2193"