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

Can someone tell me whats wrong with my code?


achap89
 Share

Recommended Posts

Ok so I get the else statements but when all the if statements are followed it says type mismatch error.

> Private Sub btnJail_Click()
> If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
>     If LenB(txtPlayerName.Text) <> 0 Then
>         Call SetPlayerMap(txtPlayerName.Text, "50")
>     Else
>         Call AddText("Please enter a name.", BRIGHTRED)
>     End If
> Else
>         Call AddText("You are not authorized to carry out that action.", BRIGHTRED)
> End If
> End Sub
Link to comment
Share on other sites

@Psiworld:

> Ok so I get the else statements but when all the if statements are followed it says type mismatch error.

I think its because of the 0 in If LenB(txtPlayerName.Text) <> 0 Then…. try this
```
Private Sub btnJail_Click()
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
    If LenB(txtPlayerName.Text) <> vbnullstring Then
        Call SetPlayerMap(txtPlayerName.Text, "50")
    Else
        Call AddText("Please enter a name.", BRIGHTRED)
    End If
Else
        Call AddText("You are not authorized to carry out that action.", BRIGHTRED)
End If
End Sub
```
Link to comment
Share on other sites

Then its prob to do with this line
```
Call SetPlayerMap(txtPlayerName.Text, "50")
```
For SetPlayermap you need (index, "50"), so since its not the player who is typing it, yes u need to index of the player's name in txtPlayerName. But thats written as a String, not a long which Index needs to be.

Try….
```
Private Sub btnJail_Click()
Dim NameIndex As Long
    NameIndex = FindPlayer(txtPlayerName.text)
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
    If LenB(txtPlayerName.Text) <> vbnullstring Then
        Call SetPlayerMap(NameIndex, "50")
    Else
        Call AddText("Please enter a name.", BRIGHTRED)
    End If
Else
        Call AddText("You are not authorized to carry out that action.", BRIGHTRED)
End If
End Sub
```
Link to comment
Share on other sites

it may not be this certain error but the code will not ever work. Your trying to warp a person client side which is impossible otherwise I could open up a normal eclipse source (and add in buttons that let me warp e.t.c) and connect to someones game (and as you can Imagen although would be fun for me it wouldn't be for anyone else). You wont be able to set someones map client side period.
Link to comment
Share on other sites

your setmap arguments need to be numbers, not strings.
```
Private Sub btnJail_Click()
Dim NameIndex As Long
    NameIndex = FindPlayer(txtPlayerName.text)
If GetPlayerAccess(MyIndex) >= ADMIN_MAPPER Then
    If LenB(txtPlayerName.Text) <> vbnullstring Then
        Call SetPlayerMap(NameIndex, 50)
    Else
        Call AddText("Please enter a name.", BRIGHTRED)
    End If
Else
        Call AddText("You are not authorized to carry out that action.", BRIGHTRED)
End If
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...