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

Did i do this right?


Jooshua6
 Share

Recommended Posts

Kinda.  The way you have it there, it'll say: "Hello, young [class] come forth.", then it'll immediately say "This scripted tile has no apparent use." right after that.  You should add a new case, case 1, right before case else, then cut and paste the if/elseif/end if section to case 1.
Link to comment
Share on other sites

ok
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
If GetPlayerClass(Index) = 0 Then
    Call PlayerMsg(Index, "Hello, young knight come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 2 Then
    Call PlayerMsg(Index, "HEllo, young archer come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 3 Then
    Call PlayerMsg(Index, "HEllo, young wizard come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 4 Then
    Call PlayerMsg(Index, "Hello, young shaman come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 5 Then
    Call PlayerMsg(Index, "HEllo, young summoner come forth.", YELLOW)
End If
Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
Exit Sub

Case Else
Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
Exit Sub
End Select
End Sub
```
Link to comment
Share on other sites

really ok thanks so much ima try that and see if it works
so it should be like this?
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
Select Case Script
Case 0
If GetPlayerClass(Index) = 0 Then
    Call PlayerMsg(Index, "Hello, young knight come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 2 Then
    Call PlayerMsg(Index, "HEllo, young archer come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 3 Then
    Call PlayerMsg(Index, "HEllo, young wizard come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 4 Then
    Call PlayerMsg(Index, "Hello, young shaman come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 5 Then
    Call PlayerMsg(Index, "HEllo, young summoner come forth.", YELLOW)
End If

End Select
End Sub
```
Link to comment
Share on other sites

Of course, this would also work:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
If GetPlayerClass(Index) = 0 Then
    Call PlayerMsg(Index, "Hello, young knight come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 2 Then
    Call PlayerMsg(Index, "HEllo, young archer come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 3 Then
    Call PlayerMsg(Index, "HEllo, young wizard come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 4 Then
    Call PlayerMsg(Index, "Hello, young shaman come forth.", YELLOW)
ElseIf GetPlayerClass(Index) = 5 Then
    Call PlayerMsg(Index, "HEllo, young summoner come forth.", YELLOW)
End If

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
Now, you'll be using Scripted Tile #1

As for the script itself, that's correct.  But there are better ways, you can use a Select Case.

Watch:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
Select Case GetPlayerClass(Index)
Case 0
    Call PlayerMsg(Index, "Hello, young knight come forth.", YELLOW)
Case 2
    Call PlayerMsg(Index, "HEllo, young archer come forth.", YELLOW)
Case 3
    Call PlayerMsg(Index, "HEllo, young wizard come forth.", YELLOW)
Case 4
    Call PlayerMsg(Index, "Hello, young shaman come forth.", YELLOW)
Case 5
    Call PlayerMsg(Index, "HEllo, young summoner come forth.", YELLOW)
End Select

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
Just as the main Select Case, compares the variable "Script" with 0, 1, etc, your new one is comparing "GetPlayerClass" to whatever the "Case" is.  In this case, if it's 0, it will do that one thing, if it's 1, etc.

Though, this could probably be refined further, if you just wanted it to display the class name, you could just use the command "GetPlayerClassName", and do this:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
    Call PlayerMsg(Index, "Hello, young " & GetPlayerClassName(Index) & " come forth.", YELLOW)

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
Link to comment
Share on other sites

@Jooshua6:

> ok ill try that
> still doing same thing?

Well, there's always another (and more complicated) way of doing it:
```
Call PlayerMsg(Index, "Hello, young " & GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "Name") & " come forth.", YELLOW)
```It's still 1 line, and would still take less computation.
Link to comment
Share on other sites

dude it still has that space did i do it wrong?
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
        Call PlayerMsg(Index, "Hello, young " & Trim(GetPlayerClassName(Index)) & " come forth.", YELLOW)

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
Link to comment
Share on other sites

@Jooshua6:

> dude it still has that space did i do it wrong?
> ```
> ' Executes when a player steps onto a scripted tile.
> Sub ScriptedTile(Index, Script)
>   Select Case Script
>       Case 0
>         Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
>         Exit Sub
>     Case 1
>         Call PlayerMsg(Index, "Hello, young " & Trim(GetPlayerClassName(Index)) & " come forth.", YELLOW)
>
>       Case Else
>         Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
>         Exit Sub
>   End Select
> End Sub
> ```

Bobosk will probably come back in here and tell me what _I_ did wrong.

Anyway, just use this, see if it works:
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
        Call PlayerMsg(Index, "Hello, young " & GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "Name") & " come forth.", YELLOW)

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
Link to comment
Share on other sites

ok thats prbly y cause spaces in classes nopee thats not it none of the classes have spaces?ill post again my main.txt
```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
        Call PlayerMsg(Index, "Hello, young " & GetVar("Classes\Class" & GetPlayerClass(Index) & ".ini", "CLASS", "Name") & " come forth.", YELLOW)

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```can you plz check over evrything in there plz cause this is taking to long for a puny script k thanks
Link to comment
Share on other sites

i don't see anything wrong with it but maybe you should just try Admirals second one.

```
' Executes when a player steps onto a scripted tile.
Sub ScriptedTile(Index, Script)
  Select Case Script
      Case 0
        Call PlayerMsg(Index, "This scripted tile has no apparent use.", WHITE)
        Exit Sub
    Case 1
  Select Case GetPlayerClass(Index)
      Case 0
          Call PlayerMsg(Index, "Hello, young knight come forth.", YELLOW)
      Case 2
          Call PlayerMsg(Index, "HEllo, young archer come forth.", YELLOW)
      Case 3
          Call PlayerMsg(Index, "HEllo, young wizard come forth.", YELLOW)
      Case 4
          Call PlayerMsg(Index, "Hello, young shaman come forth.", YELLOW)
      Case 5
          Call PlayerMsg(Index, "HEllo, young summoner come forth.", YELLOW)
  End Select

      Case Else
        Call PlayerMsg(Index, "No tile script found. Please contact an admin to solve this problem.", WHITE)
        Exit Sub
  End Select
End Sub
```
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...