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

Smelting script problem


adamsharp
 Share

Recommended Posts

If you can fix this the fixer can use it in thier game.
```
Sub Brsm(Index)
Dim br
Dim ir
Dim st
Dim si
Dim go
Dim test
test = Rand(1,2)
si = Rand(1,2)
go = Rand(1,2)
st = Rand(1,2)
ir = Rand(1,2)
br = Rand(1,2)
If CanTake(Index, 201, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If br = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a bronze bar!", 10)
  Call GiveCurrency(Index, 211, 1)
  Call TakeItem(Index, 201, 1)
End If
If br = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 201, 1)
End If
Else
If CanTake(Index, 202, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If ir = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a iron bar!", 10)
  Call GiveCurrency(Index, 212, 1)
  Call TakeItem(Index, 202, 1)
End If
If ir = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 202, 1)
End If
Else
If CanTake(Index, 203, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If st = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a steel bar!", 10)
  Call GiveCurrency(Index, 213, 1)
  Call TakeItem(Index, 203, 1)
End If
If st = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 203, 1)
End If
Else
If CanTake(Index, 204, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If si = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a silver bar!", 10)
  Call GiveCurrency(Index, 214, 1)
  Call TakeItem(Index, 204, 1)
End If
If si = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 204, 1)
End If
Else
If CanTake(Index, 205, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If go = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a gold bar!", 10)
  Call GiveCurrency(Index, 215, 1)
  Call TakeItem(Index, 205, 1)
End If
If go = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 205, 1)
End If
Else
If CanTake(Index, 206, 1) Then
Call PlayerMsg(Index,"Attempting to smelt...", 10)
If test = 1 Then
Call PlayerMsg(Index,"Smelt successful! You get a 206 bar!", 10)
  Call GiveCurrency(Index, 216, 1)
  Call TakeItem(Index, 206, 1)
End If
If test = 2 Then
Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
Call TakeItem(Index, 206, 1)
End If
Else
Call PlayerMsg(Index,"No Ore To Smelt", 12)
End If
End Sub

```
Regards,
Adamsharp.
Link to comment
Share on other sites

OK, it should work now:
```
Sub Brsm(Index)

  Dim br
  Dim ir
  Dim st
  Dim si
  Dim go
  Dim test

  test = Rand(1,2)
  si = Rand(1,2)
  go = Rand(1,2)
  st = Rand(1,2)
  ir = Rand(1,2)
  br = Rand(1,2)

  If CanTake(Index, 201, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If br = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a bronze bar!", 10)
        Call GiveCurrency(Index, 211, 1)
        Call TakeItem(Index, 201, 1)
      End If
      If br = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 201, 1)
      End If
  ElseIf CanTake(Index, 202, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If ir = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a iron bar!", 10)
        Call GiveCurrency(Index, 212, 1)
        Call TakeItem(Index, 202, 1)
      End If
      If ir = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 202, 1)
      End If
  ElseIf CanTake(Index, 203, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If st = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a steel bar!", 10)
        Call GiveCurrency(Index, 213, 1)
        Call TakeItem(Index, 203, 1)
      End If
      If st = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 203, 1)
      End If
  ElseIf CanTake(Index, 204, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If si = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a silver bar!", 10)
        Call GiveCurrency(Index, 214, 1)
        Call TakeItem(Index, 204, 1)
      End If
      If si = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 204, 1)
      End If
  ElseIf CanTake(Index, 205, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If go = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a gold bar!", 10)
        Call GiveCurrency(Index, 215, 1)
        Call TakeItem(Index, 205, 1)
      End If
      If go = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 205, 1)
      End If
  ElseIf CanTake(Index, 206, 1) Then
      Call PlayerMsg(Index,"Attempting to smelt...", 10)
      If test = 1 Then
        Call PlayerMsg(Index,"Smelt successful! You get a 206 bar!", 10)
        Call GiveCurrency(Index, 216, 1)
        Call TakeItem(Index, 206, 1)
      End If
      If test = 2 Then
        Call PlayerMsg(Index,"Failed to smelt, ore destroyed", 12)
        Call TakeItem(Index, 206, 1)
      End If
  Else
        Call PlayerMsg(Index,"No Ore To Smelt", 12)
  End If 

End Sub

```
Haven't tested it though. Let me know how it goes.
Also, please keep everything nicely alligned as shown above. It is really hard to read code without any indentation. I'm sure you will note that too. :)

-Thanks
Link to comment
Share on other sites

yes that worked thank you

Now I have a problem with my new script WoodCutting!

```
Case 1wc(Index)

Dim R

R = Rand(1,5)

If CanTake(Index, 250, 1) Then
  Call PlayerMsg(Index,"Attempting to get wood...", 10)
If R = 1 Or If R = 2 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 1 evergreen log!", 10)
End If
If R = 3 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 2 evergreen logs!", 10)
End If
If R = 4 Or If R = 5 Then
Call PlayerMsg(Index,"Woodcutting failed, hatchet damaged!", 12)
End If
Else
Call PlayerMsg(Index,"You don't have a hatchet!", 12)
End If
End Sub

```Regards,
Adamsharp.
Link to comment
Share on other sites

```
Case 1wc(Index)

Dim R

R = Rand(1,5)

If CanTake(Index, 250, 1) Then
  Call PlayerMsg(Index,"Attempting to get wood...", 10)
If R = 1 Or R = 2 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 1 evergreen log!", 10)
End If
If R = 3 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 2 evergreen logs!", 10)
End If
If R = 4 Or R = 5 Then
Call PlayerMsg(Index,"Woodcutting failed, hatchet damaged!", 12)
End If
Else
Call PlayerMsg(Index,"You don't have a hatchet!", 12)
End If
End Sub

```
Link to comment
Share on other sites

Let's see [Probably wrong ill give it a shot]

> **Case 1wc(Index)** What the hell is this? Are you trying to make a function like Call 1Wc(index) In which case it would be Sub 1Wc
>
> Dim R
>
> R = Rand(1,5)
>
> If CanTake(Index, 250, 1) Then
>   Call PlayerMsg(Index,"Attempting to get wood…", 10)
> If R = 1 Or R = 2 Then
> Call PlayerMsg(Index,"Woodcutting successful! Found 1 evergreen log!", 10)
> It doesn't give them any items here, only a message
> ElseIf R = 3 Then
> Call PlayerMsg(Index,"Woodcutting successful! Found 2 evergreen logs!", 10)
> ElseIf R = 4 Or R = 5 Then
> Call PlayerMsg(Index,"Woodcutting failed, hatchet damaged!", 12)
> Else
> Call PlayerMsg(Index,"You don't have a hatchet!", 12)
> End If
> End Sub

So…
Edit the # # of the give items
```
Sub 1Wc

Dim R

R = Rand(1,5)

If CanTake(Index, 250, 1) Then
  Call PlayerMsg(Index,"Attempting to get wood...", 10)
If R = 1 Or R = 2 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 1 evergreen log!", 10)
Call GiveItem(index, #, #)
ElseIf R = 3 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 2 evergreen logs!", 10)
Call GiveItem(index, #, #)
ElseIf R = 4 Or If R = 5 Then
Call PlayerMsg(Index,"Woodcutting failed, hatchet damaged!", 12)
Else
Call PlayerMsg(Index,"You don't have a hatchet!", 12)
End If
End Sub
```Should be just about right unless i've overlooked something D:
Link to comment
Share on other sites

You don't use If before each condition. You only use If at the beginning of the line.

```
Sub 1Wc(index)

R = Rand(1,5)

If CanTake(Index, 250, 1) Then
  Call PlayerMsg(Index,"Attempting to get wood...", 10)
If R = 1 Or R = 2 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 1 evergreen log!", 10)
Call GiveItem(index, #, #)
ElseIf R = 3 Then
Call PlayerMsg(Index,"Woodcutting successful! Found 2 evergreen logs!", 10)
Call GiveItem(index, #, #)
ElseIf R = 4 Or R = 5 Then
Call PlayerMsg(Index,"Woodcutting failed, hatchet damaged!", 12)
Else
Call PlayerMsg(Index,"You don't have a hatchet!", 12)
End If

End If
End Sub
```
The sub parameters need an index, and there was an unended If-statement.
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...