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

How to connect 2 cases?


apf42589
 Share

Recommended Posts

How do you connect 2 cases together?
i have the same script just on different cases…

Case 1
dim weapon
    Weapon = GetPlayerWeaponSlot(index)
    If weapon = 0 Then
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
      ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
      Call GoWoodcutting(index, 1, 10, "Logs")
      Else
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
    End If
  End Select
End Sub
  Case Else
    Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)

  Case Else

and when i put a the same script on the case under it the second case dont work only the first one....

  Thank You,
                APF
Link to comment
Share on other sites

Case 1
dim weapon
    Weapon = GetPlayerWeaponSlot(index)
    If weapon = 0 Then
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
      ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
      Call GoWoodcutting(index, 1, 10, "Logs")
      Else
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
    End If
  Case Else
    Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
  End Select
End Sub

^ Use that, it's cuz you had End Select and End Sub at the end of the Case.

End Select goes at the end of ALL the cases, not each one. And End Sub goes at the bottom of the Sub.
Link to comment
Share on other sites

@dg1423:

> ^ Use that, it's cuz you had End Select and End Sub at the end of the Case.
>
> End Select goes at the end of ALL the cases, not each one. And End Sub goes at the bottom of the Sub.

so i can do this?

      Case 0
dim weapon
    Weapon = GetPlayerWeaponSlot(index)
    If weapon = 0 Then
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
      ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
      Call GoWoodcutting(index, 1, 10, "Logs")
      Else
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
    End If
  Case Else
    Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
End Sub

Case 1
    dim weapon
    Weapon = GetPlayerWeaponSlot(index)
    If weapon = 0 Then
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
      ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
      Call GoWoodcutting(index, 1, 10, "Logs")
      Else
      Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
    End If
  End Select
End Sub
  Case Else
    Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
    End Select
End Sub

scripiting is confusing @.@
Link to comment
Share on other sites

Umm no… I guess I don't have anything to do, I'll rewrite it.

> Case 0
> dim weapon
> Weapon = GetPlayerWeaponSlot(index)
> If weapon = 0 Then
> Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
> ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
> Call GoWoodcutting(index, 1, 10, "Logs")
> Else
> Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
> End If
>
> Case 1
> Weapon = GetPlayerWeaponSlot(index)
> If weapon = 0 Then
> Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
> ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
> Call GoWoodcutting(index, 1, 10, "Logs")
> Else
> Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
> End If
>
> End Select
> End Sub

Didn't I already tell some1 today (you?) that you can't declare the same variable twice?

Anyway, I only checked your script structure, not the commands. I asume you have a GoWoodcutting sub.
Link to comment
Share on other sites

@AdrianC:

> Umm no… I guess I don't have anything to do, I'll rewrite it.
>
> Didn't I already tell some1 today (you?) that you can't declare the same variable twice?
>
> Anyway, I only checked your script structure, not the commands. I asume you have a GoWoodcutting sub.

=\ yea sorry new to scripting xD… but ty very much ill try it now, and yea i have that sub.
Link to comment
Share on other sites

Well, since they're exactly the same thing, you could do this:

> **Case 0, 1**
>   dim weapon
>   Weapon = GetPlayerWeaponSlot(index)
>   If weapon = 0 Then
>       Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
>   ElseIf GetPlayerInvItemNum(index, weapon) = 33 Then
>       Call GoWoodcutting(index, 1, 10, "Logs")
>   Else
>       Call PlayerMsg(index, "You don't have a Axe to chop this tree.", 15)
>   End If
>
> End Select
> End Sub

I don't think a whole lot of people know about that.  If you simply separate two cases with a comma, it'll work for both cases.  I don't see why you need it here, but there are certainly situations where that's helpful.
Link to comment
Share on other sites

@AdrianC:

> He wanted to learn how to use two different cases. It just happened that he used the same code for both. I can't see why you would ever make two cases which are exactly the same.

The only use I've thought of for making two cases the same is weighted probabilities (like if you want something to happen 3/8 of the time, another thing to happen 1/8 of the time and a third thing to happen 4/8 of the time), but I'm sure there's other uses for it, too.
Link to comment
Share on other sites

@AdrianC:

> If they are exactly the same, no matter what probability, the same thing happens every single time.

yea and i was editing the 2nd case for fishing, i wouldnt use the same code.  Before only case 0 worked and case 1 didnt so i wanted to see how to "connect" them properly >.>

APF
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...