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

Is there something worng with this?


VitinhooxD
 Share

Recommended Posts

Hello Eclipse!I'm having trouble with this script:
```
Sub SetPlayer1stJob(index , profession)
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "Jobs" , "FirstJob" , ""& profession)
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , "0")
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , "0")
Call PlayerMsg(index , "You now can do " & profession & " ! " ,12)
End Sub
```
It should put what there is write here : Call SetPlayer1stJob(index , **profession** ) in a ini file , but it put "" … Could someone help me?
Link to comment
Share on other sites

no i'll try this , thanks Admiral!

EDIT: the first sub worked but now this one is not working:
```
Sub JobMode1(index , job ,  mode)
Dim needtool
Dim give
Dim givevalue
Dim giveexp
Dim needtoup
Dim lvl
Dim exp
Dim skillaction
Dim succed
Dim chance
Dim rnd
Dim succedmsg

succedmsg = GetVar("Skills\" & job & ".ini" , ""& mode , "SuccedMsg")
chance = GetVar("Skills\" & job & ".ini" , ""& mode , "Chance")
skillaction = GetVar("Skills\" & job & ".ini" , "Info" , "SkillAction")
succed = GetVar("Skills\" & job & ".ini" , "Info" , "Succed")
lvl = GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level")
needtoup = GetVar("jobexp.ini" , "Exp" , ""& lvl)
exp =  GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp")
needtool = GetVar("Skills\" & job & ".ini" , ""& mode , "NeedTool")
give = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveNum")
givevalue = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveValue")
giveexp = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp")

If GetPlayer1stJob(index) = Int(job) Then
  If GetPlayerInvItemNum(index , GetPlayerWeaponSlot(index)) = needtool Then
rnd = Rand(Chance , 1)
Select Case rnd

Case 1
Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
Call Give_Currency(index , ""& give , ""& givevalue )
      If exp = ""  Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& giveexp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
Else
exp = Int(exp) + giveexp
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& exp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
          If Int(exp) >= Int(needtoup) Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , Int(lvl) + 1) 
Call BattleMsg(index , "You are in level " & lvl & " in " & job & " ! " , 2 , 1 )
          End If
      End If
Case Else
'nothing lol
End Select
  Else
      Call BattleMsg(index , "You need te right tool to " & skillaction & " here , please search/buy it!" , 12 , 0)
  End If
Else
Call BattleMsg(index , "You need to do " & job & " to " & skillaction & " here ! " , 12 ,1 )
End If

End Sub

```

Whats wrong?
Link to comment
Share on other sites

Whenever you get a value from an INI that needs to be a number, GetVar will still return a string; which means if you want to use it with anything number-related, you'll have to Int() it.
e.g.
giveexp = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp")
Would be:
giveexp = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp"))
Link to comment
Share on other sites

Great but now the error is Type mismatch "string"  on line 19

gere is the sub

```
Sub JobMode1(index , job ,  mode)
Dim needtool
Dim give
Dim givevalue
Dim giveexp
Dim needtoup
Dim lvl
Dim exp
Dim skillaction
Dim succed
Dim chance
Dim rnd
Dim succedmsg

succedmsg = GetVar("Skills\" & job & ".ini" , ""& mode , "SuccedMsg")
chance = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "Chance"))
skillaction = GetVar("Skills\" & job & ".ini" , "Info" , "SkillAction")
succed = GetVar("Skills\" & job & ".ini" , "Info" , "Succed")
lvl = Int(GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level"))
needtoup = Int(GetVar("jobexp.ini" , "Exp" , ""& lvl))
exp =  Int(GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp"))
needtool = Int( GetVar("Skills\" & job & ".ini" , ""& mode , "NeedTool"))
give = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveNum"))
givevalue = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveValue"))
giveexp = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp"))

If GetPlayer1stJob(index) = Int(job) Then
  If GetPlayerInvItemNum(index , GetPlayerWeaponSlot(index)) = needtool Then
rnd = Rand(Chance , 1)
Select Case rnd

Case 1
Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
Call Give_Currency(index , ""& give , ""& givevalue )
      If exp = ""  Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& giveexp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
Else
exp = Int(exp) + giveexp
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& exp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
          If Int(exp) >= Int(needtoup) Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , Int(lvl) + 1) 
Call BattleMsg(index , "You are in level " & lvl & " in " & job & " ! " , 2 , 1 )
          End If
      End If
Case Else
'nothing lol
End Select
  Else
      Call BattleMsg(index , "You need te right tool to " & skillaction & " here , please search/buy it!" , 12 , 0)
  End If
Else
Call BattleMsg(index , "You need to do " & job & " to " & skillaction & " here ! " , 12 ,1 )
End If

End Sub
```
+X
Link to comment
Share on other sites

Okay, time to debug.
Replace the sub with this, run it, and let me know if the Call PlayerMsg gets to 2 or 3 in your chatbox:
```
Sub JobMode1(index , job ,  mode)
Dim needtool
Dim give
Dim givevalue
Dim giveexp
Dim needtoup
Dim lvl
Dim exp
Dim skillaction
Dim succed
Dim chance
Dim rnd
Dim succedmsg
Call PlayerMsg(Index, "1", WHITE)
succedmsg = GetVar("Skills\" & job & ".ini" , ""& mode , "SuccedMsg")
chance = GetVar("Skills\" & job & ".ini" , ""& mode , "Chance")
skillaction = GetVar("Skills\" & job & ".ini" , "Info" , "SkillAction")
succed = GetVar("Skills\" & job & ".ini" , "Info" , "Succed")
lvl = GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level")
needtoup = GetVar("jobexp.ini" , "Exp" , ""& lvl)
exp =  GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp")
needtool = GetVar("Skills\" & job & ".ini" , ""& mode , "NeedTool")
give = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveNum")
givevalue = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveValue")
giveexp = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp")
Call PlayerMsg(Index, "2", WHITE)
If GetPlayer1stJob(index) = Int(job) Then
Call PlayerMsg(Index, "2", WHITE)
If GetPlayerInvItemNum(index , GetPlayerWeaponSlot(index)) = Int(needtool) Then
rnd = Rand(Chance , 1)
Select Case rnd

Case 1
Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
Call Give_Currency(index , ""& give , ""& givevalue )
If exp = ""  Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& giveexp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
Else
exp = Int(exp) + giveexp
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& exp)
Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
If Int(exp) >= Int(needtoup) Then
Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , Int(lvl) + 1) 
Call BattleMsg(index , "You are in level " & lvl & " in " & job & " ! " , 2 , 1 )
End If
End If
End Select
Else
Call BattleMsg(index , "You need te right tool to " & skillaction & " here , please search/buy it!" , 12 , 0)
End If
Else
Call PlayerMsg(Index, "3", WHITE)
Call BattleMsg(index , "You need to do " & job & " to " & skillaction & " here ! " , 12 ,1 )
End If
End Sub

```

EDIT: Wait, we have Emblem and Bobosk looking at this topic; let's see if one of them reply.
Link to comment
Share on other sites

What exactly is the value of "Job".
Because if it's a string, you can't Int() it.

(A string being anything that's not a number xD)

**Edit:**
Try this: (Trim just removes spaces from the start/end of a string)
```
If GetPlayer1stJob(index) = Trim(Job) Then

```
Link to comment
Share on other sites

Yeah , i'll try that thanks!

EDIT: Made some fix but now the error is Subscript out of range line 29

```
Sub JobMode1(index , job ,  mode)
Dim needtool
Dim give
Dim givevalue
Dim giveexp
Dim needtoup
Dim lvl
Dim exp
Dim skillaction
Dim succed
Dim chance
Dim rand
Dim succedmsg

  Call PlayerMsg(Index, "1", WHITE)
succedmsg = GetVar("Skills\" & job & ".ini" , ""& mode , "SuccedMsg")
chance = GetVar("Skills\" & job & ".ini" , ""& mode , "Chance")
skillaction = GetVar("Skills\" & job & ".ini" , "Info" , "SkillAction")
succed = GetVar("Skills\" & job & ".ini" , "Info" , "Succed")
lvl = GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level")
needtoup = GetVar("jobexp.ini" , "Exp" , ""& lvl)
exp =  GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp")
needtool = GetVar("Skills\" & job & ".ini" , ""& mode , "NeedTool")
give = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveNum")
givevalue = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveValue")
giveexp = GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp")
  Call PlayerMsg(Index, "2", WHITE)
If GetPlayer1stJob(index) = Trim(job) Then
Call PlayerMsg(Index, "3", WHITE)
  If GetPlayerInvItemNum(index , GetPlayerWeaponSlot(index)) = needtool Then
      rand = Rand(Chance , 1)
      Select Case rand

      Case 1
        Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
        Call Give_Currency(index , ""& give , ""& givevalue )
        If exp = ""  Then
            Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& giveexp)
            Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
        Else
            exp = exp + giveexp
            Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& exp)
            Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
            If exp >= needtoup Then
              Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , Int(lvl) + 1) 
              Call BattleMsg(index , "You are in level " & lvl & " in " & job & " ! " , 2 , 1 )
            End If
        End If
      End Select
  Else
      Call BattleMsg(index , "You need te right tool to " & skillaction & " here , please search/buy it!" , 12 , 0)
  End If
Else
Call PlayerMsg(Index, "4", WHITE)
  Call BattleMsg(index , "You need to do " & job & " to " & skillaction & " here ! " , 12 ,1 )
End If
End Sub

```
Link to comment
Share on other sites

yeah

EDIT: current sub
```
Sub JobMode1(index , job ,  mode)
Dim needtool
Dim give
Dim givevalue
Dim giveexp
Dim needtoup
Dim lvl
Dim exp
Dim skillaction
Dim succed
Dim chance
Dim rand
Dim succedmsg

  Call PlayerMsg(Index, "1", WHITE)
succedmsg = GetVar("Skills\" & job & ".ini" , ""& mode , "SuccedMsg")
chance = Int(GetVar("Skills\" & job & ".ini" ,  ""& mode , "Chance"))
skillaction = GetVar("Skills\" & job & ".ini" , "Info" , "SkillAction")
succed = GetVar("Skills\" & job & ".ini" , "Info" , "Succed")
lvl = GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level")
needtoup = Int(GetVar("jobexp.ini" , "Exp" , ""& lvl))
exp = GetVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp")
needtool = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "NeedTool"))
give = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveNum"))
givevalue = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveValue"))
giveexp = Int(GetVar("Skills\" & job & ".ini" , ""& mode , "GiveExp"))
  Call PlayerMsg(Index, "2", WHITE)
If GetPlayer1stJob(index) = job Then
Call PlayerMsg(Index, "3", WHITE)
  If GetPlayerInvItemNum(index , GetPlayerWeaponSlot(index)) = needtool Then
      rand = Rand(Chance , 1)
      Select Case rand

      Case 1
        Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
        Call Give_Currency(index , ""& give , ""& givevalue )
        If exp = ""  Then
            Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& giveexp)
            Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
        Else
            exp = exp + giveexp
            Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Exp" , ""& exp)
            Call BattleMsg(index , "You gained " & giveexp & " in " & job & " ! " , 2 , 1 )
            If exp >= needtoup Then
              Call PutVar("Accounts\" & GetPlayerName(index) & ".ini" , "FirstJob" , "Level" , Int(lvl) + 1) 
              Call BattleMsg(index , "You are in level " & lvl & " in " & job & " ! " , 2 , 1 )
            End If
        End If
      End Select
  Else
      Call BattleMsg(index , "You need te right tool to " & skillaction & " here , please search/buy it!" , 12 , 0)
  End If
Else
Call PlayerMsg(Index, "4", WHITE)
  Call BattleMsg(index , "You need to do " & job & " to " & skillaction & " here ! " , 12 ,1 )
End If
End Sub

```
Current error type mysmatch line 20
Link to comment
Share on other sites

Try changing the this:
```
rand = Rand(Chance , 1)
```
to this:
```
rand = Rand(1, Chance)
```
And this
```
Call BattleMsg(index , " & succedmsg & "  , GREEN , 1 )
```
to this:
```
Call BattleMsg(index , succedmsg  , GREEN , 1 )
```
and this:
```
Call Give_Currency(index , ""& give , ""& givevalue )
```
to this:
```
Call Give_Currency(index , int(give) , int(givevalue))
```
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...