Jump to content

Is telnet useable in custom scripts like IronPython!


Satis

Recommended Posts

As the title says, is it possible to use telnet in IronPython custom script?

 

If it possible, could some one give an example of how to connect to telnet and execute and command from there?

 

Reason why I'm asking is this:

I'm doing an 7D2D build on our private server for A17.2+ and there is an option to enable an terminal window from the serverconfig file of the game, but when I enable that one and try set the options to use Console input and Console output to show it in the web console and to execute commands there, it does not take that terminal window and nothing is hapening.

If I set it to use the output log and use the RCON as input commands, it shows as it should so no big problem there.

 

Now the problem is that once the server shuts down it does not execute the Stop Console Commands that is set to shutdown the game correctly and auto save the game.

So I was thinking of adding a custom script to log into telnet of the server and send a save command or shutdown command to the server before stop server event.

 

Hope it makes cense.

 

Kind regards

Satis

Link to comment
Share on other sites

[Make a script with the `Before Stopped`event]

Give this a try:

 

import clr;
clr.AddReference("TCAdmin.GameHosting.SDK");
import TCAdmin.GameHosting.SDK.Objects.Server
import TCAdmin.GameHosting.SDK.Objects.Service

service = Service(ThisService_ServiceId)
server = Server(service.ServerId)
server.GameAdminService.ExecuteRConCommand(ThisService_ServiceId, service.Variables["RConPassword"], "CommandHere"); 

 

Never tested it just of the top of my head but the basic idea is there.

Edited by alexr03
Added imports
Link to comment
Share on other sites

Thanks for the help alexr03.

 

Now for others interesting in how to send an recon command from a script, here is what alexr03 and me tried out that was working perfectly.

 

For testing we used a custom script (IronPython -> Custom Icon)

import clr;
clr.AddReference("TCAdmin.GameHosting.SDK");
from TCAdmin.GameHosting.SDK.Objects import Service, Server

service = Service(ThisService.ServiceId)
server = Server(service.ServerId)
response = server.GameAdminService.ExecuteRConCommand(ThisService.ServiceId, service.Variables["RConPassword"], "commandToExecute");

Script.WriteToConsole(response)

 

For the production on the "Before Stopped" event, we used this:

import clr;
clr.AddReference("TCAdmin.GameHosting.SDK");
from TCAdmin.GameHosting.SDK.Objects import Service, Server

service = Service(ThisService_ServiceId)
server = Server(service.ServerId)
server.GameAdminService.ExecuteRConCommand(ThisService_ServiceId, service.Variables["RConPassword"], "commandToExecute");

 

Basically the only thing that is different between those 2 codes are that in the testing button, we print the respond from the command executed.

 

Hope this can help others as well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Who's Online   0 Members, 0 Anonymous, 37 Guests (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use