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

Jail Command.


Ertzel
 Share

Recommended Posts

I can't seem to get this /jail command to work. I have it in the right spots and everything, but each time I do the command /jail player (and put in the players name) all it says is…

The command is /jail player

This is what the code looks like…

```
Case "/jail"
        If GetPlayerAccess(Index) > 0 Then
            If LBound(TextSay) > 0 Then
              Dim Target

              Target = FindPlayer(TextSay(1))

              If Target > 0 Then
                  Call PlayerWarp(Target, 16, 16, 14)
                  Call PlayerMsg(Target, "You have been jailed!", BRIGHTGREEN)
                  Call PlayerMsg(Index, GetPlayerName(Target) & " has been jailed!", BRIGHTGREEN)
              Else
                  Call PlayerMsg(Index, "The player " & TextSay(1) & " is either offline or doesn't exist.", BRIGHTRED)
              End If
            Else
              Call PlayerMsg(Index, "The command is /jail player", BRIGHTRED)
            End If
        End If

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

Don't Dim Target in the command, dim it where the rest are at.
Sub Commands(Index)
Dim TextSay
Dim PlayerID
Dim MapNum
Thats at the top of the commands.
Try that and let me know.

EDIT: PlayerID is dim as that, so replace target with PlayerID instead
If that still fails try mine, it works perfect for me.
```
Case "/jail"
If GetPlayerAccess(Index) > 0 Then
PlayerID = FindPlayer(TextSay(1))

If PlayerID > 0 Then
Call PlayerWarp(PlayerID, 90, 15, 4)
Call PlayerMsg(index, "You have been jailed!", BRIGHTGREEN)
Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)
                End If
Else
Call PlayerMsg(Index, "Player is not online.", WHITE)
End If
Exit Sub

```
Link to comment
Share on other sites

```
Case "/jail"
If GetPlayerAccess(Index) < 1 Then
Call PlayerMsg(Index, "You don't have the appropriate access level.", BRIGHTRED)

Exit Sub
End If

If UBound(TextSay) < 1 Then
Call PlayerMsg(Index, "The command is: " & TextSay(0) & " name", WHITE)

Exit Sub
End If

PlayerID = FindPlayer(TextSay(1))

If PlayerID < 1 Then
Call PlayerMsg(Index, "The player doesn't exist or is offline.", BRIGHTRED)

Exit Sub
End If

Call PlayerWarp(PlayerID, 90, 15, 4)
Call PlayerMsg(Index, "You have been jailed!", BRIGHTGREEN)
Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)

Exit Sub
```
I still don't get why people don't use UBound or inverse if-checks :icon_nif:.

Regards,
  Godlord.
Link to comment
Share on other sites

@Godlord:

> ```
> Case "/jail"
> If GetPlayerAccess(Index) < 1 Then
> Call PlayerMsg(Index, "You don't have the appropriate access level.", BRIGHTRED)
>
> Exit Sub
> End If
>
> If UBound(TextSay) < 1 Then
> Call PlayerMsg(Index, "The command is: " & TextSay(0) & " name", WHITE)
>
> Exit Sub
> End If
>
> PlayerID = FindPlayer(TextSay(1))
>
> If PlayerID < 1 Then
> Call PlayerMsg(Index, "The player doesn't exist or is offline.", BRIGHTRED)
>
> Exit Sub
> End If
>
> Call PlayerWarp(PlayerID, 90, 15, 4)
> Call PlayerMsg(Index, "You have been jailed!", BRIGHTGREEN)
> Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)
>
> Exit Sub
> ```
> I still don't get why people don't use UBound or inverse if-checks :icon_nif:.
>
> Regards,
>   Godlord.

Actually wouldn't it be-
```
Case "/jail"
If GetPlayerAccess(Index) < 1 Then
Call PlayerMsg(Index, "You don't have the appropriate access level.", BRIGHTRED)

Exit Sub
End If

If UBound(TextSay) < 1 Then
Call PlayerMsg(Index, "The command is: " & TextSay(0) & " name", WHITE)

Exit Sub
End If

PlayerID = FindPlayer(TextSay(1))

If PlayerID < 1 Then
Call PlayerMsg(Index, "The player doesn't exist or is offline.", BRIGHTRED)

Exit Sub
End If

Call PlayerWarp(PlayerID, 90, 15, 4)
Call PlayerMsg(PlayerID, "You have been jailed!", BRIGHTGREEN)
Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)

Exit Sub
```(Replaced where it said "Call PlayerMsg(Index, "You have been jailed!", BRIGHTGREEN)")
Right?
Link to comment
Share on other sites

@Spechno:

> Actually wouldn't it be-
> ```
> Case "/jail"
> If GetPlayerAccess(Index) < 1 Then
> Call PlayerMsg(Index, "You don't have the appropriate access level.", BRIGHTRED)
>
> Exit Sub
> End If
>
> If UBound(TextSay) < 1 Then
> Call PlayerMsg(Index, "The command is: " & TextSay(0) & " name", WHITE)
>
> Exit Sub
> End If
>
> PlayerID = FindPlayer(TextSay(1))
>
> If PlayerID < 1 Then
> Call PlayerMsg(Index, "The player doesn't exist or is offline.", BRIGHTRED)
>
> Exit Sub
> End If
>
> Call PlayerWarp(PlayerID, 90, 15, 4)
> Call PlayerMsg(PlayerID, "You have been jailed!", BRIGHTGREEN)
> Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)
>
> Exit Sub
> ```(Replaced where it said "Call PlayerMsg(Index, "You have been jailed!", BRIGHTGREEN)")
> Right?

I copied it and fixed the common mistakes such as the missing UBound and the inverse ifs.

@Kratos:

> Don't Dim Target in the command, dim it where the rest are at.
> Sub Commands(Index)
> Dim TextSay
> Dim PlayerID
> Dim MapNum
> Thats at the top of the commands.
> Try that and let me know.
>
> EDIT: PlayerID is dim as that, so replace target with PlayerID instead
> If that still fails try mine, it works perfect for me.
> ```
> Case "/jail"
> If GetPlayerAccess(Index) > 0 Then
> PlayerID = FindPlayer(TextSay(1))
>
> If PlayerID > 0 Then
> Call PlayerWarp(PlayerID, 90, 15, 4)
> Call PlayerMsg(index, "You have been jailed!", BRIGHTGREEN)
> Call PlayerMsg(Index, GetPlayerName(PlayerID) & " has been jailed!", BRIGHTGREEN)
>                 End If
> Else
> Call PlayerMsg(Index, "Player is not online.", WHITE)
> End If
> Exit Sub
>
> ```

"Call PlayerMsg(**index**, "You have been jailed!", BRIGHTGREEN)"

Regards,
  Godlord.
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...