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

Need Help Fixing Up This Script (SOLVED)


Kimimaru
 Share

Recommended Posts

i Think that MsgBox isn't a valid command. try this way.

' **Executes QueryBoxes.
  Sub QueryBox(index, script)

      Value = GetVar("responses.ini", "Responses", Cstr(index))

      Select Case script

' Asks player to input new password.

    Case 0

    Select Case Value

  Case GetVar("Accounts\" & GetPlayerName(Index) & "_Info.ini", "ACCESS", "Password")

      Call PlayerQueryBox(Index, "Please enter your new password.", 1)

' Rejects password if it's incorrect.

      Case Else

      Call PlayerMsg(index ,  "I'm sorry, but that password is incorrect. Please visit me when you know your password and want to change it.", 0)
      Call PlayerMsg(index ,  "Incorrect Password!" , 0 )

  End Select

    Case 1

  Select Case Value

' Asks you to input a new password if the password you inputted is the same as the current one.

  Case GetVar("Accounts\" & GetPlayerName(Index) & "_Info.ini", "ACCESS", "Password")

      Call PlayerQueryBox(Index, "I'm sorry, but that's your current password. Please choose a different password.", 1) 

  Case Else

' Sets password length requirement; must be at least 3 characters long.

      If Len(Value) < 3 Then

      Call PlayerQueryBox(Index, "Your password must be at least 3 characters in length! Please choose another password.", 1)

      Else

' Changes password.

      Call PutVar("Accounts\" & GetPlayerName(Index) & "_Info.ini", "ACCESS", "Password", ""& Value)

      Call PlayerMsg(index ,  "Your password has been changed to: " & Value & ". Please come back to me whenever you want to change your password again.", 0)
      Call PlayerMsg(index , "Password Changed Successfully!" , 0 )

      End If

  End Select
    End Select

    End Sub

' Executes whenever a scripted NPC does an action.
Sub ScriptedNPC(Index, Script)
  Select Case Script

  ' Allows players to change their password by talking to an NPC

      Case 1       

        Call PlayerMsg(index ,  "Hey, I'm the password changer. I can change your password for you.", 0)

        Call PlayerQueryBox(Index, "Please enter your password.", 0)

      Case Else
        Call PlayerMsg(Index, "No NPC script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub

I hope i could help.
Link to comment
Share on other sites

Thanks for trying to help, but the MsgBox is a valid command. As I stated in the first post, the whole script works; it's just that it doesn't keep the new password saved when you log off and then back on. I need help saving the new password, somehow.

Thanks again for trying to help.
Link to comment
Share on other sites

I tried that while I was working on the script, and it didn't work. I don't think you understand what I need help with. I need to add something, that will permanently save the password that it put in the .INI file after you've finished changing your password. It already saves the password, and I've checked that in the .INI file, but as soon as I log off and then go back on, it reverts back to the old one. Since this is the case, the password you type on login is the same as the old one, as well; however, I don't want it like that.

I appreciate the help, though.
Link to comment
Share on other sites

I like your scripting style Kimimaru.

I think when the player logs in, his information is read from the INI from the server, and when he logs out, it updates it.

You could try something like this, in the sub where the player logs out (I think it's Sub LeaveGame or something along the lines of that):
Dim Value
Value = GetVar("Accounts\" & GetPlayerName(Index) & "_Info.ini", "ACCESS", "Password")
Call PutVar("Accounts\" & GetPlayerName(Index) & "_Info.ini", "ACCESS", "Password", Trim(Value))

That way, right when the player logs out, it updates his password one last time.
Link to comment
Share on other sites

Yeah, I replaced all the **GetPlayerName(Index)** variables with **GetPlayerLogin(Index)** variables. I ran the script and checked the file. Just like before, if you check it after you talk to the NPC, the password is changed; however, if you check it after you log off, the password reverts back to the original password.
Link to comment
Share on other sites

Try adding a putvar to the script that put's the password in a different .ini, and then in the leavegame sub, put the same putvar as the one that I fixed, but have it put a variable called "Password" so add
```
Dim Password
Password = GetVar("/Accounts/" & GetPlayerLogin(Index) & "_Info", "NEWPASSWORD", "Password")

```And the first putvar I told you to add, use this
```
Call PutVar("/Accounts/" & GetPlayerLogin(Index) & "_Info", "NEWPASSWORD", "Password", Trim(Value))

```Add that somewhere in the password script.
And then in the leavegame script again, put this before the end sub
```
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "_Info.ini", "ACCESS", "Password", Password)

```
If that doesn't work, I'm out of ideas.
Link to comment
Share on other sites

Thanks for the help, but unfortunately it still didn't work, and I'm still experiencing the same problem. Did I correctly install what you suggested?

I put this at the top of the Leavegame Sub:

```
Dim Password
Password = GetVar("/Accounts/" & GetPlayerLogin(Index) & "_Info", "NEWPASSWORD", "Password")

```
After that, I put this at the bottom of the Leavegame Sub:

```
Call PutVar("Accounts\" & GetPlayerLogin(Index) & "_Info.ini", "ACCESS", "Password", Password)

```
Then, I put this in the appropriate spot in the QueryBox Sub:

```
Call PutVar("/Accounts/" & GetPlayerLogin(Index) & "_Info", "NEWPASSWORD", "Password", Trim(Value))

```
Link to comment
Share on other sites

@Kimimaru:

> I'm not sure, but that's possible. Ne0n told me that I need to use timers to keep the password saved, but I'm not sure if that's correct. Maybe someone can confirm that?

That could work if you set a timer to activate and store the password after the player is well logged out.
Link to comment
Share on other sites

I'm gonna go ahead and say, yes, yes it is!
```
Sub SavePlayer(ByVal Index As Long)
    Dim FileName As String
    Dim f As Long 'File
    Dim I As Integer

    On Error Resume Next

    ' Save login information first
    FileName = App.Path & "\Accounts\" & Trim$(Player(Index).Login) & "_Info.ini"

    Call PutVar(FileName, "ACCESS", "Login", Trim$(Player(Index).Login))
    Call PutVar(FileName, "ACCESS", "Password", Trim$(Player(Index).Password))
    Call PutVar(FileName, "ACCESS", "Email", Trim$(Player(Index).Email))

    ' Make the directory
    If LCase$(Dir(App.Path & "\Accounts\" & Trim$(Player(Index).Login), vbDirectory)) <> LCase$(Trim$(Player(Index).Login)) Then
        Call MkDir(App.Path & "\Accounts\" & Trim$(Player(Index).Login))
    End If

    ' Now save their characters
    For I = 1 To MAX_CHARS
        FileName = App.Path & "\Accounts\" & Trim$(Player(Index).Login) & "\Char" & I & ".dat"

        ' Save the character
        f = FreeFile
        Open FileName For Binary As #f
        Put #f, , Player(Index).Char(I)
        Close #f

    Next I
End Sub

Public Sub LoadPlayer(ByVal Index As Long, ByVal Name As String)
    Dim f As Long
    Dim I As Integer
    Dim FileName As String

    On Error GoTo PlayerErr

    Call ClearPlayer(Index)

    ' Load the account settings
    FileName = App.Path & "\Accounts\" & Trim$(Name) & "_Info.ini"

    Player(Index).Login = Name
    Player(Index).Password = GetVar(FileName, "ACCESS", "Password")
    Player(Index).Email = GetVar(FileName, "ACCESS", "Email")

    ' Load the .dat
    For I = 1 To MAX_CHARS
        FileName = App.Path & "\Accounts\" & Trim$(Player(Index).Login) & "\Char" & I & ".dat"

        f = FreeFile
        Open FileName For Binary As #f
            Get #f, , Player(Index).Char(I)
        Close #f
    Next I

    Exit Sub

PlayerErr:
    Call MsgBox("Couldn't load index " & Index & " for " & Name & "!", vbCritical)
    Call DestroyServer
End Sub
```(Sourced)
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...