Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
frmWarp
#1
ok i decided to make a new frm called frmwarp....it comes out when i press the F6 button...
this is the code i used
Code:
Private Sub cancelcmd_Click()
Unload Me
End Sub

Private Sub Form_Load()

End Sub

Private Sub warpcmd_Click()
If selectwarp.Text = "Castle" Then Call AddText("Cannot warp at the moment", BrightRed)
End Sub
this way when i select Castle in the combo box and then i press the warp button the frm call the AddText Cannot warp atm.....how to make the player warp??what is the code??
thx Big Grin
Reply
#2
First, you need to use proper nesting.

The If Statement you've written isn't... So to speak, well enough to handle what you want.

[code]
If Then


Else

Reply
#3
uhm...don't understand sorry Sad
Quote:Private Sub Command1_Click()
If Castle Then Call PlayerWarp(MyIndex, 2, 2, 2)
Else: Call AddText("Cannot warp at the moment", BrightRed)
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub
where do i have to put the conditions??
Reply
#4
Castle IS the condition.

Code:
If x = 1 Then

X = 1 is the CONDITION. So... Now that you know that, your condition is when the radio button's caption is "Castle" right?

Code:
Private Sub Command1_Click()
    If selectwarp.Text = "Castle" Then
        Call PlayerWarp(MyIndex, 2, 2, 2)
    Else
        Call AddText("Cannot warp at the moment", BrightRed)
    End If
End Sub

Private Sub Command2_Click()
    Unload Me
End Sub

Note how I nested it for you.
That's how it should look like.
Reply
#5
srry but it doesnt work for me Sad
this is the code
Code:
Private Sub cancelcmd_Click()
Unload Me
End Sub

Private Sub warpcmd_Click()
If selectwarp.Text = "Castle" Then
        Call PlayerWarp(MyIndex, 2, 2, 2)
    Else
        Call AddText("Cannot warp at the moment", BrightRed)
    End If
End Sub
it gives me an error and says that Call PlayerWarp is wrong.....
Then i tried with other functions:
Code:
Private Sub cancelcmd_Click()
Unload Me
End Sub

Private Sub warpcmd_Click()
If selectwarp.Text = "Castle" Then
        Call WarpTo(2)
    Else
        Call AddText("Cannot warp at the moment", BrightRed)
    End If
End Sub
this way it works but i can only decide the map,its not working for X and Y
Reply
#6
Actually you can do:
Code:
If statement then code
No end if needed, but it doesn't support elseif

Code:
If x > 0 then call add(x)
Reply
#7
Here's an easy fix.

In the client, go to the code.

Search for where it says...

Code:
Sub WarpTo(ByVal MapNum As Long)
Dim Packet As String
    
    Packet = "WARPTO" & SEP_CHAR & MapNum & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub

Add this one

Code:
Sub WarpTo2(ByVal MapNum As Long, x As Long, y As Long)
Dim Packet As String
    
    Packet = "WARPTO2" & SEP_CHAR & MapNum & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub

Now, you're done with the client.

Go to the server. Search for this code in the server.

Code:
' ::::::::::::::::::::::::
    ' :: Warp to map packet ::
    ' ::::::::::::::::::::::::
    If LCase(Parse(0)) = "warpto" Then
        ' Prevent hacking
        If GetPlayerAccess(Index) < ADMIN_MAPPER Then
            Call HackingAttempt(Index, "Admin Cloning")
            Exit Sub
        End If
        
        ' The map
        n = Val(Parse(1))
        
        ' Prevent hacking
        If n < 0 Or n > MAX_MAPS Then
            Call HackingAttempt(Index, "Invalid map")
            Exit Sub
        End If
        
        Call PlayerWarp(Index, n, GetPlayerX(Index), GetPlayerY(Index))
        Call PlayerMsg(Index, "You have been warped to map #" & n, BrightBlue)
        Call AddLog(GetPlayerName(Index) & " warped to map #" & n & ".", ADMIN_LOG)
        Exit Sub
    End If

And add this one
Code:
' :::::::::::::::::::::::::::::::::
    ' :: Warp(map,x,y) to map packet ::
    ' :::::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "warpto2" Then
        ' Prevent hacking[commented]
        'just in case you want this to be a admin only
        'feature if you want it to be an admin only feature
        'uncomment the commented code below
        '/////////////////////////////////////////////////
        'If GetPlayerAccess(Index) < ADMIN_MAPPER Then
        '    Call HackingAttempt(Index, "Admin Cloning")
        '    Exit Sub
        'End If
        '/////////////end admin only code/////////////////
        
        ' The map
        n = Val(Parse(1))
        
        'x and y
        x = Val(Parse(2))
        y = Val(Parse(3))
        
        ' Prevent hacking
        If n < 0 Or n > MAX_MAPS Then
            Call HackingAttempt(Index, "Invalid map")
            Exit Sub
        End If
        
        'prevent out of range[hacking]
        If x > MAX_MAPX Or y > MAX_MAPY Or x < 0 Or y < 0 Then
            Call HackingAttempt(Index, "Warping out of range")
            Exit Sub
        End If
        
        Call PlayerWarp(Index, n, x, y)
        Call PlayerMsg(Index, "You have been warped to map #" & n & "(" & x & "," & y & ")", BrightBlue)
        Call AddLog(GetPlayerName(Index) & " warped to map #" & n & "(" & x & "," & y & ")", ADMIN_LOG)
        Exit Sub
    End If

And there you have it. It should work. Now all you have to do Client side is call WarpTo2(mapnum,x,y).

Basically, this...

Code:
Private Sub cancelcmd_Click()
Unload Me
End Sub

Private Sub warpcmd_Click()
If selectwarp.Text = "Castle" Then
        Call WarpTo2(2, 2, 2)
    Else
        Call AddText("Cannot warp at the moment", BrightRed)
    End If
End Sub

@Stomach: I know that, but I told him if he wants to be somewhat proper with it, and allow for more complex if statements, nesting and using End If is essential.
Reply
#8
he could also use
Code:
Select Case SelectWarp.Text
Case "Castle"
    Call WarpTo2(m,x,y)
Case Else
    Call AddText("no such destination", BrightRed)
End Select
just an idea..
Reply
#9
A case would be easier for multiple destinations.
Reply
#10
Quote: ::::::::::::::::::::::::
' :: Warp to map packet ::
' ::::::::::::::::::::::::
If LCase(Parse(0)) = "warpto" Then
' Prevent hacking
If GetPlayerAccess(Index) < ADMIN_MAPPER Then
Call HackingAttempt(Index, "Admin Cloning")
Exit Sub
End If

' The map
n = Val(Parse(1))

' Prevent hacking
If n < 0 Or n > MAX_MAPS Then
Call HackingAttempt(Index, "Invalid map")
Exit Sub
End If

Call PlayerWarp(Index, n, GetPlayerX(Index), GetPlayerY(Index))
Call PlayerMsg(Index, "You have been warped to map #" & n, BrightBlue)
Call AddLog(GetPlayerName(Index) & " warped to map #" & n & ".", ADMIN_LOG)
Exit Sub
End If
ehm....i dont have this code in the server...thx anyway
Reply
#11
i only have this
Code:
Case "warpto"
        Call PlayerWarp(index, Val(Parse(1)), GetPlayerX(index), GetPlayerY(index))
        Exit Sub
Reply
#12
You do...

I pulled it from a blank 3.03...

Maybe it might be different... If you're using MSE.

Ugh, I hate MSE. >.>

[Edit]

... Wow. That's. Gay. xD

Okay just... Throw that in. Don't use If, use a Case.
Reply
#13
so i have simply to put your code
Code:
' :::::::::::::::::::::::::::::::::
    ' :: Warp(map,x,y) to map packet ::
    ' :::::::::::::::::::::::::::::::::
    If LCase(Parse(0)) = "warpto2" Then
        ' Prevent hacking[commented]
        'just in case you want this to be a admin only
        'feature if you want it to be an admin only feature
        'uncomment the commented code below
        '/////////////////////////////////////////////////
        'If GetPlayerAccess(Index) < ADMIN_MAPPER Then
        '    Call HackingAttempt(Index, "Admin Cloning")
        '    Exit Sub
        'End If
        '/////////////end admin only code/////////////////
      
        ' The map
        n = Val(Parse(1))
      
        'x and y
        x = Val(Parse(2))
        y = Val(Parse(3))
      
        ' Prevent hacking
        If n < 0 Or n > MAX_MAPS Then
            Call HackingAttempt(Index, "Invalid map")
            Exit Sub
        End If
      
        'prevent out of range[hacking]
        If x > MAX_MAPX Or y > MAX_MAPY Or x < 0 Or y < 0 Then
            Call HackingAttempt(Index, "Warping out of range")
            Exit Sub
        End If
      
        Call PlayerWarp(Index, n, x, y)
        Call PlayerMsg(Index, "You have been warped to map #" & n & "(" & x & "," & y & ")", BrightBlue)
        Call AddLog(GetPlayerName(Index) & " warped to map #" & n & "(" & x & "," & y & ")", ADMIN_LOG)
        Exit Sub
    End If
in the server under
Code:
Case "warpto"
        Call PlayerWarp(index, Val(Parse(1)), GetPlayerX(index), GetPlayerY(index))
        Exit Sub
and then in the client
Code:
Select Case SelectWarp.Text
Case "Castle"
    Call WarpTo2(m,x,y)
Case Else
    Call AddText("no such destination", BrightRed)
End Select
right??
Reply
#14
not exactly
you must change this
Code:
If LCase(Parse(0)) = "warpto2" Then
to this
Code:
Case "warpto2"
and remove the last
end if
Reply
#15
I get this error: Sub or function not defined
Reply
#16
this is the error
Reply
#17
it doesnt work also without the index.....the problem is the "Call warpto2"
Reply
#18
little help??? Big Grin
Reply
#19
Matt Wrote:Here's an easy fix.

In the client, go to the code.

Search for where it says...

Code:
Sub WarpTo(ByVal MapNum As Long)
Dim Packet As String
    
    Packet = "WARPTO" & SEP_CHAR & MapNum & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub

Add this one

Code:
Sub WarpTo2(ByVal MapNum As Long, x As Long, y As Long)
Dim Packet As String
    
    Packet = "WARPTO2" & SEP_CHAR & MapNum & SEP_CHAR & x & SEP_CHAR & y & SEP_CHAR & END_CHAR
    Call SendData(Packet)
End Sub
that bit you still need to do
Reply
#20
thaaaaaaaaaaanks!!!!!!! Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin Big Grin
now it works!!!!
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
Reply
#21
Lol, the newbs.

You can totally change it if you want. I dun care, It took me no longer than 5 minutes. Tongue
Reply
#22
and if i want to add a level restriction?? i tried with
Code:
Case "Field1"
    If Player(MyIndex).Level < 13 Then
    Call WarpTo2(2, 15, 15)
    Else: Call AddText("You must be level 13 or higher to warp", BrightRed)
    End If

but doesnt seem to work
Reply
#23
Code:
Case "Field1"
If GetPlayerLevel(MyIndex) >= 13 Then
            Call WarpTo2(2, 15, 15)
        Else
            Call AddText("You must be level 13 or higher to warp", BrightRed)
        End If

That should work.
Reply
#24
thx Big Grin
Reply
#25
stilatore Wrote:and if i want to add a level restriction?? i tried with
Code:
Case "Field1"
    If Player(MyIndex).Level < 13 Then
    Call WarpTo2(2, 15, 15)
    Else: Call AddText("You must be level 13 or higher to warp", BrightRed)
    End If

but doesnt seem to work

That coding style is... Something I've never seen before...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)