|
| 1 | +--- |
| 2 | +sidebar_position: 3 |
| 3 | +sidebar_label: TCAdmin2 advanced module for WHMCS |
| 4 | +--- |
| 5 | + |
| 6 | +# TCAdmin2 advanced module for WHMCS |
| 7 | + |
| 8 | +:::info |
| 9 | +This software comes `as is` and no support for the module will be provided by TCAdmin. TCAdmin support is limited to the TCAdmin software. |
| 10 | +::: |
| 11 | + |
| 12 | +## Requirements |
| 13 | + |
| 14 | +1. You must have a fully installed, licensed and configured TCAdmin control panel. This includes game files, automation setup and email templates. |
| 15 | +2. Fully installed and configured WHMCS installation. |
| 16 | +3. PHP curl extension enabled. |
| 17 | + |
| 18 | +## Download |
| 19 | + |
| 20 | +The tcadmin2_advanced module can be downloaded from our [**client area**](http://clients.tcadmin.com/downloads.php?action=displaycat&catid=5). |
| 21 | + |
| 22 | +## WHMCS module features |
| 23 | + |
| 24 | +1. Supports the following WHMCS module commands: |
| 25 | + - **Create:** Create game and voice servers automatically. Game switching is supported. |
| 26 | + - **Suspend/Unsuspend/Terminate:** Automatically suspend/enable/delete game and voice servers. |
| 27 | + - **Change Package:** Update a game/voice servers private status, branding and slots. |
| 28 | + - **Change Password:** Change the client's TCAdmin password from within WHMCS. |
| 29 | +2. Direct client login from WHMCS to TCAdmin. |
| 30 | +3. Configurable options and custom fields can be used to set all the TCAdmin billing API attributes. This makes it flexible. You configure your packages exactly the way you want them. |
| 31 | + |
| 32 | +:::info example |
| 33 | +Configure your packages to ask your clients for their game server's location, hostname and passwords in the WHMCS order page. |
| 34 | +::: |
| 35 | + |
| 36 | +## TCAdmin billing API configuration settings |
| 37 | + |
| 38 | +Configure TCAdmin according to the [Billing API configuration page](/billing-api/intro). |
| 39 | + |
| 40 | +## WHMCS Module Installation and Configuration |
| 41 | + |
| 42 | +### Installing the Files |
| 43 | + |
| 44 | +- Extract the contents of the `tcadmin2_advanced.zip` file to the path `/whmcs-root/modules/servers/tcadmin2_advanced` in your WHMCS installation. |
| 45 | + |
| 46 | +### Adding the TCAdmin Server |
| 47 | + |
| 48 | +1. Log in to WHMCS. |
| 49 | +2. Go to `Configuration` > `Products/Services` > `Servers` and Click on Add New Server. |
| 50 | +3. Enter the server `name`, `hostname`, `ip address`, `port`, select server type `tcadmin2_advanced` and enter the admin login and password that will be used. If you don't use a hostname to access your control panel (cp.yourdomain.com:8880) enter your website's ip address (xxx.xxx.xxx.xxx:8880) in the hostname field. |
| 51 | + |
| 52 | +## Creating Products in WHMCS |
| 53 | + |
| 54 | +Create your product [according to the WHMCS documentation](http://docs.whmcs.com/Products_and_Services). Configure with custom fields and configurable options to ask for `location`, `hostname`, `slots`, etc. |
| 55 | + |
| 56 | +### Module settings |
| 57 | + |
| 58 | +The most common attributes can be configured in the module settings tab. Other attributes can be configured in the file specified in the "Config File" field. The default config file is "default_values.php". You can use a config file that has different values depending on the configuration that is required for each product. Assign a "Custom Field" or "Configuration Option" from the list next to each attribute. When the module command is executed the tcadmin attribute will take the value of that field or option. |
| 59 | + |
| 60 | +:::tip |
| 61 | +Why are your dropdowns empty? You need to configure your product with custom fields or configurable options for `hostname`, `location`, `slots`, etc. Then you will see them in the dropdowns. |
| 62 | +::: |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +- **Config File** |
| 67 | + - The file that contains the default values used for the TCAdmin billing API. |
| 68 | + - Contains more options not shown (commandline parameters, service level, game switching, etc). |
| 69 | + - Default file: `default_values.php` |
| 70 | + |
| 71 | +- **Game ID** |
| 72 | + - The game id that will be created. |
| 73 | + - If blank, a game server will not be created. |
| 74 | + |
| 75 | +- **Game Slots** |
| 76 | + - Number of slots for the game server. |
| 77 | + - If blank, a game server will not be created. |
| 78 | + - Can include prefixes PRI and PUB for private or public servers. |
| 79 | + - Example: PRI8 for a private server with 8 slots. |
| 80 | + |
| 81 | +- **Game Private** |
| 82 | + - 1 if the game server is private, 0 if public. |
| 83 | + - Default: 0. |
| 84 | + |
| 85 | +- **Game Branded** |
| 86 | + - 1 if the game server is branded, 0 if not. |
| 87 | + - Default: 0. |
| 88 | + |
| 89 | +- **Game Datacenter** |
| 90 | + - Datacenter id where the game server will be created. |
| 91 | + - Required for game server creation. |
| 92 | + |
| 93 | +- **Game Hostname** |
| 94 | + - Hostname of the game server. |
| 95 | + - Automatically generated if datacenter is specified. |
| 96 | + |
| 97 | +- **Game RCon Password** |
| 98 | + - RCon password for the game server. |
| 99 | + - Automatically generated if not specified. |
| 100 | + |
| 101 | +- **Game Private Password** |
| 102 | + - Private password for the game server. |
| 103 | + - Automatically generated if not specified. |
| 104 | + |
| 105 | +- **Voice ID** |
| 106 | + - Voice id that will be created. |
| 107 | + - For Teamspeak 2 virtual server, use TEAMSPEAK. |
| 108 | + - For Teamspeak 3 virtual server, use TEAMSPEAK3. |
| 109 | + - If blank, no voice server will be created. |
| 110 | + - For TEAMSPEAK3, upload and download quotas can be sent. |
| 111 | + |
| 112 | +- **Voice Slots** |
| 113 | + - Number of slots for the voice server. |
| 114 | + - If valid voice id provided and this is blank, it uses game_slots. |
| 115 | + - Can include prefixes PRI and PUB for private or public servers. |
| 116 | + - Example: PRI8 for a private server with 8 slots. |
| 117 | + |
| 118 | +- **Voice Branded** |
| 119 | + - 1 if the voice server is private, 0 if public. |
| 120 | + - Default: 0. |
| 121 | + |
| 122 | +- **Voice Datacenter** |
| 123 | + - Datacenter id where the voice server will be created. |
| 124 | + - Required for voice server creation. |
| 125 | + |
| 126 | +- **Voice Hostname** |
| 127 | + - Hostname of the voice server. |
| 128 | + - Automatically generated if not specified. |
| 129 | + |
| 130 | +- **Voice RCon Password** |
| 131 | + - RCon password for the voice server. |
| 132 | + - Automatically generated if not specified. |
| 133 | + |
| 134 | +- **Voice Private Password** |
| 135 | + - Private password for the voice server. |
| 136 | + - Automatically generated if not specified. |
| 137 | + |
| 138 | +- **Reseller Packages** |
| 139 | + - To create reseller packages, leave game and voice info blank. |
| 140 | + - Set "Config File" to "reseller_values.php". |
| 141 | + - Create the file in tcadmin2_advanced folder with specified lines. |
| 142 | + |
| 143 | +```php |
| 144 | +<?php |
| 145 | + include('default_values.php'); |
| 146 | + $billing_api_values["role_id"]="3"; //The reseller role id to assign to the user. |
| 147 | + $billing_api_values["package_id"]="1"; //The reseller package id to assign to the user. |
| 148 | +?> |
| 149 | +``` |
| 150 | + |
| 151 | +## Advanced Configuration (Optional) |
| 152 | + |
| 153 | +### Config File (default_values.php) |
| 154 | + |
| 155 | +To configure attributes that are not on the Module settings edit file default_values.php located in `\whmcs\modules\servers\tcadmin2_advanced`. You can configure them to take the value of a `Custom Field`, `Configuration Option` or a fixed value. |
| 156 | + |
| 157 | +- To configure it to use a `Custom Field` set the value to `CustomField:FieldName` |
| 158 | + |
| 159 | +:::info example |
| 160 | +`CustomField:Hostname` |
| 161 | +::: |
| 162 | + |
| 163 | +- To configure it to use a `Configuration Option` set the value to `ConfigOption:OptionName` |
| 164 | + |
| 165 | +:::info example |
| 166 | +`ConfigOption:Slots` |
| 167 | +::: |
| 168 | + |
| 169 | +:::info full example in code |
| 170 | +```php |
| 171 | +$billing_api_values["game_additional_slots"] = "ConfigOption:Extra Slots"; |
| 172 | +``` |
| 173 | +::: |
| 174 | + |
| 175 | +### Sending Custom Variable Values |
| 176 | + |
| 177 | +You can specify custom variable values directly by using the following formats. The variable name is case sensitive. If custom variable values are not specified the default value will be used. |
| 178 | + |
| 179 | +```php title="For game servers:" |
| 180 | +$billing_api_values["gamevar_VariableName"] = "ConfigOption:ReservedSlots"; |
| 181 | +``` |
| 182 | + |
| 183 | +```php title="For voice servers:" |
| 184 | +$billing_api_values["voicevar_VariableName"] = "CustomField:VoiceCodec"; |
| 185 | +``` |
| 186 | + |
| 187 | +```php title="Minecraft example:" |
| 188 | +$billing_api_values["gamevar_Xms"] = "2048"; |
| 189 | +$billing_api_values["gamevar_Xmx"] = "2048"; |
| 190 | +``` |
| 191 | + |
| 192 | +### Sending Allowed Games for Game Switching |
| 193 | + |
| 194 | +Use game_id_switch_# to specify the game ids that the service can be switched to. For example this allows the game server to switch to game ids 10, 20, 30.: |
| 195 | + |
| 196 | +```php |
| 197 | +$billing_api_values["game_id_switch_1"]=10; |
| 198 | +$billing_api_values["game_id_switch_2"]=20; |
| 199 | +$billing_api_values["game_id_switch_3"]=30; |
| 200 | +``` |
| 201 | + |
| 202 | +### Custom Config File |
| 203 | + |
| 204 | +In some cases you might need to set different API values or execute custom code for a specific game. To use different config files for a game you can create a new text file with .php extension in the tcadmin2_advanced folder with these lines. Set the name of the custom file in your product's module settings. |
| 205 | + |
| 206 | +```php |
| 207 | +<?php |
| 208 | + include('default_values.php'); |
| 209 | + //Your code here |
| 210 | +?> |
| 211 | +``` |
| 212 | + |
| 213 | +### Examples |
| 214 | + |
| 215 | +The following example sets the game slots to a fixed value of 100. The Xmx and Xms variables are set to 2048 (2GB). All the other values configured in default_values.php are left the same. Upload to the tcadmin2_advanced folder. In the product's module settings configure this file as the config file instead of `default_values.php`. |
| 216 | + |
| 217 | +```php |
| 218 | +<?php |
| 219 | + include('default_values.php'); |
| 220 | + $billing_api_values["game_slots"] = 100; |
| 221 | + $billing_api_values["gamevar_Xms"] = "2048"; |
| 222 | + $billing_api_values["gamevar_Xmx"] = "2048"; |
| 223 | +?> |
| 224 | +``` |
| 225 | + |
| 226 | +#### Don't start the game server after it has been created. |
| 227 | + |
| 228 | +```php |
| 229 | +<?php |
| 230 | + include('default_values.php'); |
| 231 | + $billing_api_values["game_start"] = 0; |
| 232 | +?> |
| 233 | +``` |
| 234 | + |
| 235 | +#### The following example sends a different game id depending the location selected by the client. You must have a custom field named Location. |
| 236 | + |
| 237 | +```php |
| 238 | +<?php |
| 239 | +include('default_values.php'); |
| 240 | +switch ($params["customfields"]["Location"]) |
| 241 | +{ |
| 242 | +case "1": |
| 243 | + $billing_api_values["game_id"] = 11; |
| 244 | + break; |
| 245 | +case "2": |
| 246 | + $billing_api_values["game_id"] = 12; |
| 247 | + break; |
| 248 | +} |
| 249 | +?> |
| 250 | +``` |
| 251 | + |
| 252 | +#### Set CPU priority to above normal. |
| 253 | + |
| 254 | +```php |
| 255 | +<?php |
| 256 | + include('default_values.php'); |
| 257 | + //Valid values are: Idle BelowNormal Normal AboveNormal High RealTime |
| 258 | + $billing_api_values["game_priority"] = "AboveNormal"; |
| 259 | +?> |
| 260 | +``` |
| 261 | + |
| 262 | +#### Set CPU and memory limits. |
| 263 | + |
| 264 | +```php |
| 265 | +<?php |
| 266 | + include('default_values.php'); |
| 267 | + $billing_api_values["game_cpu"] = "75"; |
| 268 | + $billing_api_values["game_memory"] = "2048"; |
| 269 | +?> |
| 270 | +``` |
| 271 | + |
| 272 | +### Minecraft Example |
| 273 | + |
| 274 | +Create a configurable option named Ram with values 512MB, 1GB, 1.5GB. The values of slots, Xms and Xmx variables are set depending on its value. Create a config file in the tcadmin2_advanced folder named minecraft.php with these lines. In the product's module settings set the config file to minecraft.php. |
| 275 | + |
| 276 | +```php |
| 277 | +<?php |
| 278 | +include('default_values.php'); |
| 279 | +switch ($params["configoptions"]["Ram"]) |
| 280 | +{ |
| 281 | +case "512MB": |
| 282 | + $billing_api_values["gamevar_Xms"] = "512"; |
| 283 | + $billing_api_values["gamevar_Xmx"] = "512"; |
| 284 | + $billing_api_values["game_slots"] = 12; |
| 285 | + break; |
| 286 | +case "1GB": |
| 287 | + $billing_api_values["gamevar_Xms"] = "1024"; |
| 288 | + $billing_api_values["gamevar_Xmx"] = "1024"; |
| 289 | + $billing_api_values["game_slots"] = 20; |
| 290 | + break; |
| 291 | +case "1.5GB": |
| 292 | + $billing_api_values["gamevar_Xms"] = "1512"; |
| 293 | + $billing_api_values["gamevar_Xmx"] = "1512"; |
| 294 | + $billing_api_values["game_slots"] = 35; |
| 295 | + break; |
| 296 | +case "2GB": |
| 297 | + $billing_api_values["gamevar_Xms"] = "2048"; |
| 298 | + $billing_api_values["gamevar_Xmx"] = "2048"; |
| 299 | + $billing_api_values["game_slots"] = 40; |
| 300 | + break; |
| 301 | +} |
| 302 | +?> |
| 303 | +``` |
| 304 | + |
| 305 | +### Create a reseller package |
| 306 | + |
| 307 | +- Create a reseller package in settings > reseller packages. In the list of reseller packages you can find the package id that you will need for the WHMCS configuration. |
| 308 | +- create a file named reseller.php in the tcadmin2_advanced folder with these lines: |
| 309 | + |
| 310 | +```php |
| 311 | +<?php |
| 312 | + include('default_values.php'); |
| 313 | + //Your code here |
| 314 | + $billing_api_values["role_id"]="3"; |
| 315 | + $billing_api_values["package_id"]="12345"; |
| 316 | +?> |
| 317 | +``` |
| 318 | + |
| 319 | +- Change the value of role_id to the reseller role id (default reseller role id is 3) |
| 320 | +- Change the value of package_id to the id of the package you want to assign. |
| 321 | +- Select your reseller product in WHMCS. In the module settings tab set the config file to reseller.php |
| 322 | + |
| 323 | +### Other configuration parameters |
0 commit comments