Jump to content

Create a custom game server page in your control panel.


LFA

Recommended Posts

Save this code to a text file named CustomPage.aspx in TCAdmin Control Panel\Web\Templates

 

<%@ Page LANGUAGE="VB" %>

<%@ Register TagPrefix="cc1" Namespace="TCAdminSDK.Web.UI" Assembly="TCAdminSDK" %>
<html>
<head>
   <title><%=TCAdminSDK.Web.Templates.GetCustomTitle() %> - Custom Page</title>
 <SCRIPT LANGUAGE="VB" RUNAT="server">

   Private _SelectedService As TCAdminSDK.Objects.Service
   Public ReadOnly Property SelectedService() As TCAdminSDK.Objects.Service
       Get
           If _SelectedService Is Nothing Then
               _SelectedService = New TCAdminSDK.Objects.Service
               _SelectedService.ServiceID = Request.QueryString("serviceid")
               If _SelectedService.Find() Then

                   ' ''''''''''''''''''' '
                   'Basic security check '
                   ' ''''''''''''''''''' '

                   Select Case TCAdminSDK.Web.Session.CurrentUserType
                       Case TCAdminSDK.Objects.UserType.Admin, TCAdminSDK.Objects.UserType.SubAdmin

                           ' ''''''''''''''''''''''''''''''''''''''' '
                           'Admin and subadmin always has permission '
                           ' ''''''''''''''''''''''''''''''''''''''' '

                       Case TCAdminSDK.Objects.UserType.User

                           ' ''''''''''''''''''''''''''''''''''''''''''' '
                           'Current user should be the game server owner '
                           ' ''''''''''''''''''''''''''''''''''''''''''' '

                           If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUser Then
                               TCAdminSDK.Web.Util.RedirectToHome()
                           End If
                       Case TCAdminSDK.Objects.UserType.SubUser

                           ' ''''''''''''''''''''''''''''''''''''''''''''''''' '
                           'Current user owner should be the game server owner '
                           ' ''''''''''''''''''''''''''''''''''''''''''''''''' '

                           If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUserParentAccount Then
                               TCAdminSDK.Web.Util.RedirectToHome()
                           End If
                   End Select
               End If
           End If
           Return _SelectedService
       End Get
   End Property

   Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
   'Redirect to login page if not authenticated
       If Not TCAdminSDK.Web.Session.IsAuthenticated Then
           Response.Redirect(String.Format("Login.aspx?returnto={0}", Request.RawUrl))
       End If
   End Sub

   Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   ' '''''''''''''''''''''''''''''''''''''''' '
   'You can add code for the page load event. '
   ' '''''''''''''''''''''''''''''''''''''''' '

   End Sub

 </SCRIPT>
</head>
<body>
  <!-- #Include virtual="header.aspx" -->

  <!-- --------------------------------- -->
  <!-- Create the breadcrumb manually  -->
  <!-- --------------------------------- -->

  <div style="width: 100%; text-align: center;" id="NavigationPanel">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="navigation_menu"><tr>

    <td style="width: 90%;" class="description_labels_small"><a href="admin_home.aspx"><%=iif(TCAdminSDK.Web.Session.CurrentUserType=TCAdminSDK.Objects.UserType.Admin, "Admin", "User") %> Home</a> > <a href="services.aspx">Game Servers</a> > <a href="<%=String.Format("service_home.aspx?serviceid={0}&svc_short_desc={1}",Me.SelectedService.ServiceId, Me.SelectedService.ShortGameNameAndSlots) %>"><%=Me.SelectedService.ShortGameNameAndSlots %></a> > <%=Me.MenuHeader1.Text %> </td>
    

<td align="right" class="description_labels_small">
<span>[</span>
<a href="login.aspx?action=LogOff">Log Out</a>
<span>]</span></td>

  </tr>
</table>

</div>

  <!-- ----------------- -->
  <!-- End of breadcrumb -->
  <!-- ----------------- -->

  <cc1:menuheader id="MenuHeader1" runat="server" Width="695px" Text="Custom Page"></cc1:menuheader>

  <!-- -------------------------- -->
  <!-- Your custom code Goes Here -->
  <!-- -------------------------- -->

  <br/>Game Server Ip: <%=Me.SelectedService.ServerIP %><br/>
  Game Server Port: <%=Me.SelectedService.ServerPort %><br/>

  <!-- ------------------ -->
  <!-- End of custom code -->
  <!-- ------------------ -->

  <!-- #Include virtual="footer.aspx" -->
</body>
</html>

Create a custom link for that game in System Settings > Custom Links with url: CustomPage.aspx?serviceid=%serviceid%

 

Then go to a game server. Click on your custom icon. It should look like a standard TCAdmin page with your custom code:

 

custompage.jpg

Link to comment
Share on other sites

  • 2 weeks later...
  • 11 months later...

Is this still working? I just tried to use it and it gave an error when the page was accessed.

 

*Edit*

 

It looks like CustomPage.aspx?serviceid=%serviceid% isn't getting the %serviceid% replaced. The link when clicked still has %serviceid% in it instead of the actual value.

Edited by CrimsonGT
Link to comment
Share on other sites

Is this still working? I just tried to use it and it gave an error when the page was accessed.

 

*Edit*

 

It looks like CustomPage.aspx?serviceid=%serviceid% isn't getting the %serviceid% replaced. The link when clicked still has %serviceid% in it instead of the actual value.

 

Yea, i can confirm this still works, use it on a custom TCAdmin for a client of mine.

Link to comment
Share on other sites

Is this still working? I just tried to use it and it gave an error when the page was accessed.

 

*Edit*

 

It looks like CustomPage.aspx?serviceid=%serviceid% isn't getting the %serviceid% replaced. The link when clicked still has %serviceid% in it instead of the actual value.

 

You need to create the link under the game server home page not under the user home page.

Link to comment
Share on other sites

Is this still working? I just tried to use it and it gave an error when the page was accessed.

 

*Edit*

 

It looks like CustomPage.aspx?serviceid=%serviceid% isn't getting the %serviceid% replaced. The link when clicked still has %serviceid% in it instead of the actual value.

Think about it... if you want your page to read a query string containing your service ID, shouldn't you already be in your service panel (game/voice server page) :smile:

Link to comment
Share on other sites

  • 1 year later...

Trying to use that code to redirect to the config editor for a specific "default config file" but I get an error. My vb skills being nearly null here is the code if someone can help troubleshooting:

 

<%@ Page LANGUAGE="VB" %>

<%@ Register TagPrefix="cc1" Namespace="TCAdminSDK.Web.UI" Assembly="TCAdminSDK" %>
<html>
<head>
   <title><%=TCAdminSDK.Web.Templates.GetCustomTitle() %> - Custom Page</title>
 <SCRIPT LANGUAGE="VB" RUNAT="server">

   Private _SelectedService As TCAdminSDK.Objects.Service
   Public ReadOnly Property SelectedService() As TCAdminSDK.Objects.Service
       Get
           If _SelectedService Is Nothing Then
               _SelectedService = New TCAdminSDK.Objects.Service
               _SelectedService.ServiceID = Request.QueryString("serviceid")
               If _SelectedService.Find() Then

                   ' ''''''''''''''''''' '
                   'Basic security check '
                   ' ''''''''''''''''''' '

                   Select Case TCAdminSDK.Web.Session.CurrentUserType
                       Case TCAdminSDK.Objects.UserType.Admin, TCAdminSDK.Objects.UserType.SubAdmin

                           ' ''''''''''''''''''''''''''''''''''''''' '
                           'Admin and subadmin always has permission '
                           ' ''''''''''''''''''''''''''''''''''''''' '

                       Case TCAdminSDK.Objects.UserType.User

                           ' ''''''''''''''''''''''''''''''''''''''''''' '
                           'Current user should be the game server owner '
                           ' ''''''''''''''''''''''''''''''''''''''''''' '

                           If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUser Then
                               TCAdminSDK.Web.Util.RedirectToHome()
                           End If
                       Case TCAdminSDK.Objects.UserType.SubUser

                           ' ''''''''''''''''''''''''''''''''''''''''''''''''' '
                           'Current user owner should be the game server owner '
                           ' ''''''''''''''''''''''''''''''''''''''''''''''''' '

                           If Not _SelectedService.UserID = TCAdminSDK.Web.Session.CurrentUserParentAccount Then
                               TCAdminSDK.Web.Util.RedirectToHome()
                           End If
                   End Select
               End If
           End If
           Return _SelectedService
       End Get
   End Property

   Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
   'Redirect to login page if not authenticated
       If Not TCAdminSDK.Web.Session.IsAuthenticated Then
           Response.Redirect(String.Format("Login.aspx?returnto={0}", Request.RawUrl))
       End If
   End Sub

   Public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   ' '''''''''''''''''''''''''''''''''''''''' '
   'You can add code for the page load event. '
   ' '''''''''''''''''''''''''''''''''''''''' '

<%
If TCAdminSDK.Web.Session.IsAuthenticated() Then
 Dim service As New TCAdminSDK.Objects.Service
 service.ServiceID = Request.QueryString("serviceid")
 If service.Find() Then
   Response.Redirect(String.Format("http://cp.roxservers.com/Templates/Default/supported_games_config_editor.aspx?serviceid={0}&filepath=Minecraft%5cserver.properties", service.serviceid))
   End If
End If
%>

   End Sub

 </SCRIPT>
</head>
<body>
  <!-- #Include virtual="header.aspx" -->

  <!-- --------------------------------- -->
  <!-- Create the breadcrumb manually  -->
  <!-- --------------------------------- -->

  <div style="width: 100%; text-align: center;" id="NavigationPanel">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="navigation_menu"><tr>

    <td style="width: 90%;" class="description_labels_small"><a href="admin_home.aspx"><%=iif(TCAdminSDK.Web.Session.CurrentUserType=TCAdminSDK.Objects.UserType.Admin, "Admin", "User") %> Home</a> > <a href="services.aspx">Game Servers</a> > <a href="<%=String.Format("service_home.aspx?serviceid={0}&svc_short_desc={1}",Me.SelectedService.ServiceId, Me.SelectedService.ShortGameNameAndSlots) %>"><%=Me.SelectedService.ShortGameNameAndSlots %></a> > <%=Me.MenuHeader1.Text %> </td>
    

<td align="right" class="description_labels_small">
<span>[</span>
<a href="login.aspx?action=LogOff">Log Out</a>
<span>]</span></td>

  </tr>
</table>

</div>

  <!-- ----------------- -->
  <!-- End of breadcrumb -->
  <!-- ----------------- -->

  <cc1:menuheader id="MenuHeader1" runat="server" Width="695px" Text="Custom Page"></cc1:menuheader>

  <!-- -------------------------- -->
  <!-- Your custom code Goes Here -->
  <!-- -------------------------- -->

  <br/>Game Server Ip: <%=Me.SelectedService.ServerIP %><br/>
  Game Server Port: <%=Me.SelectedService.ServerPort %><br/>

  <!-- ------------------ -->
  <!-- End of custom code -->
  <!-- ------------------ -->

  <!-- #Include virtual="footer.aspx" -->
</body>
</html>

Link to comment
Share on other sites

×
×
  • 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