Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] The server is available only for admins


SholT
 Share

Recommended Posts

Hi. This is my first tutorial, so please bear with us. Tutorial is written by me. This is a tutorial through which we can do to get the server to be available only for admins. Let's go :)

**Only Server-Side**

Add CheckBox in "Control", Name: chkGMOnly, Caption: Only GM's.
Now we add a script
**modHandleData**, find:
```
            If IsMultiAccounts(Name) Then
                Call AlertMsg(index, "Multiple account logins is not authorized.")
                Exit Sub
            End If
```and add below:
```
            If frmServer.chkGMOnly.Value = 1 Then
            If Player(index).Access < 1 Then
                Call AlertMsg(index, "Only the server admins.")
            Exit Sub
            End If
            End If
```
Script work 100%, tested by me :) I greet!

**Forbid copying tutorial without my knowledge**
Link to comment
Share on other sites

@Peter120:

> You sure If Player(index).Access < 1 Then ?

For your available :)
Here are the accesses:
        0\. Player
        1\. Monitor
        2\. Mapper
        3\. Developer
        4\. Creator
Link to comment
Share on other sites

  • 2 weeks later...
@abhi2011:

> What wrong is there to do?

I dont know, you have problemt with it…

Make " Add CheckBox in "Control", Name: chkGMOnly, Caption: Only GM's. "
And change Private Sub HandleLogin To

```
Private Sub HandleLogin(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
    Dim Buffer As clsBuffer
    Dim Name As String
    Dim Password As String
    Dim i As Long
    Dim n As Long

    If Not IsPlaying(Index) Then
        If Not IsLoggedIn(Index) Then
            Set Buffer = New clsBuffer
            Buffer.WriteBytes Data()
            ' Get the data
            Name = Buffer.ReadString
            Password = Buffer.ReadString

            ' Check versions
            If Buffer.ReadLong < CLIENT_MAJOR Or Buffer.ReadLong < CLIENT_MINOR Or Buffer.ReadLong < CLIENT_REVISION Then
                Call AlertMsg(Index, "Version outdated, please visit " & Options.Website)
                Exit Sub
            End If

            If isShuttingDown Then
                Call AlertMsg(Index, "Server is either rebooting or being shutdown.")
                Exit Sub
            End If

            If Len(Trim$(Name)) < 3 Or Len(Trim$(Password)) < 3 Then
                Call AlertMsg(Index, "Your name and password must be at least three characters in length")
                Exit Sub
            End If

            If Not AccountExist(Name) Then
                Call AlertMsg(Index, "That account name does not exist.")
                Exit Sub
            End If

            If Not PasswordOK(Name, Password) Then
                Call AlertMsg(Index, "Incorrect password.")
                Exit Sub
            End If

            If IsMultiAccounts(Name) Then
                Call AlertMsg(Index, "Multiple account logins is not authorized.")
                Exit Sub
            End If

            If frmServer.chkGMOnly.Value = 1 Then
            If Player(Index).Access < 1 Then
                Call AlertMsg(Index, "Server is closed!")
            Exit Sub
            End If
            End If

            ' Load the player
            Call LoadPlayer(Index, Name)
            ClearBank Index
            LoadBank Index, Name

            ' Check if character data has been created
            If LenB(Trim$(Player(Index).Name)) > 0 Then
                ' we have a char!
                HandleUseChar Index
            Else
                ' send new char shit
                If Not IsPlaying(Index) Then
                    Call SendNewCharClasses(Index)
                End If
            End If

            ' Show the player up on the socket status
            Call AddLog(GetPlayerLogin(Index) & " has logged in from " & GetPlayerIP(Index) & ".", PLAYER_LOG)
            Call TextAdd(GetPlayerLogin(Index) & " has logged in from " & GetPlayerIP(Index) & ".")

            Set Buffer = Nothing
        End If
    End If

End Sub

```
Link to comment
Share on other sites

Nope no use. Is there that possible can conflict with this? Let me try a vanilla copy

Edit: Okay the vanilla copy didnt work. Thought of reading the code. And I finally found the cause of the error. Coding mistake in the Author's part. If we have a higher access then 1 then the login will be denied. Just as Justn specified. Though Domino I still don't understand how u did it with access level set higher than 1 and logged in.
Link to comment
Share on other sites

@abhi2011:

> Nope no use. Is there that possible can conflict with this? Let me try a vanilla copy
>
> Edit: Okay the vanilla copy didnt work. Thought of reading the code. And I finally found the cause of the error. Coding mistake in the Author's part. If we have a higher access then 1 then the login will be denied. Just as Justn specified. Though Domino I still don't understand how u did it with access level set higher than 1 and logged in.

Before you login you need to be access more than 1  before closing server go in and make your character/account as admin access 5 …
Link to comment
Share on other sites

Actually there is a coding mistake. Player access < 1 means that if the player access is smaller then 1 then it denies ur login else it will accpt ur login. But Player access > 1 means that if the players access is greater then 1 then it will accpt ur login else it will deny u.
Link to comment
Share on other sites

@abhi2011:

> Actually there is a coding mistake. Player access < 1 means that if the player access is smaller then 1 then it denies ur login else it will accpt ur login. But Player access > 1 means that if the players access is greater then 1 then it will accpt ur login else it will deny u.

Where is the **coding** mistake in that? Only problem with that is, player's with access 1 (Monitors) won't be able to login ;)
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
It is kind of funny how many people here try to add tutorials without even knowing extremely basic code like this tutorial. No offense intended for the OP though, good first tutorial, certainly has it's uses.
Link to comment
Share on other sites

  • 6 months later...
> Hi. This is my first tutorial, so please bear with us. Tutorial is written by me. This is a tutorial through which we can do to get the server to be available only for admins. Let's go ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
>
> **Only Server-Side**
>
> Add CheckBox in "Control", Name: chkGMOnly, Caption: Only GM's.
>
> Now we add a script
>
> **modHandleData**, find:
>
> ```
> If IsMultiAccounts(Name) Then
>
> Call AlertMsg(index, "Multiple account logins is not authorized.")
>
> Exit Sub
>
> End If
> ```
> and add below:
>
> ```
> If frmServer.chkGMOnly.Value = 1 Then
>
> If Player(index).Access < 1 Then
>
> Call AlertMsg(index, "Only the server admins.")
>
> Exit Sub
>
> End If
>
> End If
> ```
>
> Script work 50%, tested by me ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) I not bad!
>
> **Forbid copying tutorial without my knowledge**
>
> **(Not if i have a mistake)**

Fixed your post , and here is the working version of it

Make a Checkbox name it chkGMOnly

Next find this at handleLogin

```

' Load the player

Call LoadPlayer(Index, Name)

ClearBank Index

LoadBank Index, Name

```

add this below it

```

If frmServer.chkGMOnly.Value = 1 Then

If Player(index).Access < 1 Then

Call AlertMsg(index, "Only the server admins.")

Exit Sub

End If

End If

```
Link to comment
Share on other sites

Cool, I made a similar system, but it's more of a whitelist style, on login it goes to a .txt get the name of the players allowed to enter. Gonna use it for the Closed-Beta of my game ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
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
 Share

×
×
  • Create New...