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

What does this do exactly?


Dastyruck
 Share

Recommended Posts

Dastyruck, the problem does not lie in the single line of code.  It works.
What context is the call in?  The error must lie in the code that triggers the Call.

For example, this works within the commands sub:

```
Case "/check"
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Class", GetPlayerClassName(index))
Exit Sub
```
Link to comment
Share on other sites

Hrmmm, that might be it…

Here is the whole sub though..

```
Sub SaveCharInfo(index)
On Error Resume Next
Dim sex
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Exists", "1")

Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Class", GetPlayerClassName(index) & "")
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Guild", GetPlayerGuild(index) & "")
If GetPlayerSex(index) = 0 Then
  sex = "Male"
Else
  sex = "Female"
End If
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Sex", sex & "")

Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Level", GetPlayerLevel(index) & "")
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Strenght", GetPlayerStr(index) & "")
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Defence", GetPlayerDef(index) & "")
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Speed", GetPlayerSpeed(index) & "")
Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "Info", "Magic", GetPlayerMagi(index) & "")
End Sub

Sub ClearMailBox(index)
Dim N

n = 1

Do While n < 6
  Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box" & n & "", "Empty!")
  n = n + 1
Loop
Call PlayerMsg(index, "Mailbox Cleared!", 12)
End Sub
```
Link to comment
Share on other sites

Here that sub is, quite long..

```
'===============================================
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when something on a custom menu is clicked.
Sub MenuScripts(index, Clicked_Index, Menu_Type)         
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Error Resume Next
Dim field_message
Dim menu_title
Dim n
Dim box
Dim reciever
menu_title = getplayermenuclicktitle(index)
field_message = getplayermenuclickmsg(index)

' Figure out what type of button was clicked ie picture, textbox, label.
Select Case Menu_Type

Case 1
' PICTURE WAS CLICKED
' Player has clicked a picture box whos number is clicked_index on the custom menu named menu_title
'Call playermsg(index, "Clicked  picture number " & clicked_index & " on the menu named " & menu_title, 14)

Case 2
' FIELD WAS CLICKED 
' Player has clicked a text field OK button whos number is clicked_index on the custom menu named menu_title.
'Call playermsg(index, "Clicked  field number " & clicked_index & " on the menu named " & menu_title & ". The field text was

" & field_message, 14)

Select Case menu_title

Case "mailsystem"
'*****************************************************************'
'*****************************************************************'
'XX This script has been created by Ilnair, aka Dinand Mentink  XX'
'XX Please do not give it out saying you made it, or distribute XX'
'XX it anywhere outside the Eclipse forums! Also, please always XX'
'XX distribute these credits along with the script!      XX'
'XX          www.nishansu.tk      ©Dinand Mentink (aka Ilnair)XX'
'*****************************************************************'
'*****************************************************************'
Call CustomMenuTextBox(index, 1, 180, 65, 235, "Enter a name!")
Call CustomMenuTextBox(index, 2, 180, 65, 260, "Enter a message!")
  Select Case clicked_index
      Case 1
        If Int(GetVar("mailsystem\" & field_message & ".ini", "Info", "Exists") + 0) = 0 Then
            Call CustomMenuLabel(index, 3, "Name: " & field_message, 85, 80, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 4, "Guild: Error", 85, 90, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 5, "Class: Error", 85, 100, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 6, "Sex: Error", 85, 110, 10, 0, 0, 400, 40)

            Call CustomMenuLabel(index, 7, "Level: Error", 85, 130, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 8, "Strenght: Error", 85, 140, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 9, "Defence: Error", 85, 150, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 10, "Magic: Error", 85, 160, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 11, "Speed: Error", 85, 170, 10, 0, 0, 400, 40)
            Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "tempvars", "sendto", "none")
            Exit Sub
        End If

        Call PutVar("mailsystem\" & GetPlayerName(index) & ".ini", "tempvars", "sendto", field_message & "")

        Name = field_message
        Guild = GetVar("mailsystem\" & field_message & ".ini", "Info", "Guild") & ""
        ClassName = GetVar("mailsystem\" & field_message & ".ini", "Info", "Class") & ""
        Level = GetVar("mailsystem\" & field_message & ".ini", "Info", "Level") & ""
        Strenght = GetVar("mailsystem\" & field_message & ".ini", "Info", "Strenght") & ""
        Defence = GetVar("mailsystem\" & field_message & ".ini", "Info", "Defence") & ""
        Speed = GetVar("mailsystem\" & field_message & ".ini", "Info", "Speed") & ""
        Magic = GetVar("mailsystem\" & field_message & ".ini", "Info", "Magic") & ""
        HP = GetVar("mailsystem\" & field_message & ".ini", "Info", "HP") & ""
        MP = GetVar("mailsystem\" & field_message & ".ini", "Info", "MP") & ""
        MAXHP = GetVar("mailsystem\" & field_message & ".ini", "Info", "MAXHP") & ""
        MAXMP = GetVar("mailsystem\" & field_message & ".ini", "Info", "MAXMP") & ""
        Sex = GetVar("mailsystem\" & field_message & ".ini", "Info", "Sex") & ""

        Call CustomMenuLabel(index, 3, "Name: " & Name, 85, 80, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 4, "Guild: " & Guild, 85, 90, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 5, "Class: " & ClassName, 85, 100, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 6, "Sex: " & Sex, 85, 110, 10, 0, 0, 400, 40)

        Call CustomMenuLabel(index, 7, "Level: " & Level, 85, 130, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 8, "Strenght: " & Strenght, 85, 140, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 9, "Defence: " & Defence, 85, 150, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 10, "Magic: " & Magic, 85, 160, 10, 0, 0, 400, 40)
        Call CustomMenuLabel(index, 11, "Speed: " & Speed, 85, 170, 10, 0, 0, 400, 40)
        Exit Sub

      Case 2
        reciever = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "tempvars", "sendto") & ""
            If reciever = "none" Then
              Call PlayerMsg(index, "Please chose a valid person to send a message!", 12)
              Exit Sub
            End If

        n = 1
        Do While n < 6
            If GetVar("mailsystem\" & reciever & ".ini", "mailbox", "box" & n) = "Empty!" Then
              Call PutVar("mailsystem\" & reciever & ".ini", "mailbox", "box" & n,

GetPlayerName(index) & ": " & field_message & "")
              n = 6
              Call PlayerMsg(index, "Message sent!", 10)
              Exit Sub
            End If
        n = n + 1
        Loop

        Call PlayerMsg(index, "Mailbox full!", 12)

      Case Else
        Exit Sub
  End Select
  Exit Sub
Case Else
  Exit Sub
End Select
Case 3
' LABEL WAS CLICKED
' Player has clicked a label button whos number is clicked_index on the custom menu named menu_title
'Call playermsg(index, "Clicked  label number " & clicked_index & " on the menu named " & menu_title, 14)
Select Case menu_title

  case "mailsystem"
'*****************************************************************'
'*****************************************************************'
'XX This script has been created by Ilnair, aka Dinand Mentink  XX'
'XX Please do not give it out saying you made it, or distribute XX'
'XX it anywhere outside the Eclipse forums! Also, please always XX'
'XX distribute these credits along with the script!      XX'
'XX          www.nishansu.tk      ©Dinand Mentink (aka Ilnair)XX'
'*****************************************************************'
'*****************************************************************'
      Select Case clicked_index

        Case 19
            ClearMailBox(index)

            msg1 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box1")
            msg2 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box2")
            msg3 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box3")
            msg4 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box4")
            msg5 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box5")

            Call CustomMenuLabel(index, 14, "Message 1: " & msg1, 300, 70, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 15, "Message 2: " & msg2, 300, 80, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 16, "Message 3: " & msg3, 300, 90, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 17, "Message 4: " & msg4, 300, 100, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 18, "Message 5: " & msg5, 300, 110, 10, 0, 0, 400, 40)
        Case 12
            msg1 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box1")
            msg2 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box2")
            msg3 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box3")
            msg4 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box4")
            msg5 = GetVar("mailsystem\" & GetPlayerName(index) & ".ini", "mailbox", "box5")

            Call CustomMenuLabel(index, 14, "Message 1: " & msg1, 300, 70, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 15, "Message 2: " & msg2, 300, 80, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 16, "Message 3: " & msg3, 300, 90, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 17, "Message 4: " & msg4, 300, 100, 10, 0, 0, 400, 40)
            Call CustomMenuLabel(index, 18, "Message 5: " & msg5, 300, 110, 10, 0, 0, 400, 40)

            Call PlayerMsg(index, "Refreshed mailbox!", 10)
        Case Else
            Exit Sub
      End Select

  Case Else
      Exit Sub

End Select

End Select

End Sub

```
Link to comment
Share on other sites

@Adrian:
Using & "" is a common practice to avoid errors. 
If you have a Sub Name(Index, Variable) and use Call PutVar("filename.ini", "header", "label", Variable) it will not work.  In that case, you need Call PutVar("filename.ini", "header", "label", Variable & "").  This only happens when the variable is one from the subname.

@Dastyruck:
Before you were using Sub SaveCharInfo(Index).  To activate the sub, you need a Call SaveCharInfo(Index) at some point in your main.txt.  Where are you actually using that call in your main txt?  I'm looking for something like a scripted tile, spell, command, npc that initializes the actual savecharinfo function.
Link to comment
Share on other sites

How does your sub look?  The following works:

```
Sub OnMapLoad(Index, OldMap, NewMap)
Call SaveCharInfo(Index)
End Sub
```
When I use that in conjunction with your sub, it updates the ini each time I load a map.
Is there something else in your OnMapLoad sub that might be making it not work?
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...