frmWarp - stilatore - 15-01-2008
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
Re: frmWarp - Matt2 - 15-01-2008
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
Re: frmWarp - stilatore - 15-01-2008
uhm...don't understand sorry
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??
Re: frmWarp - Matt2 - 15-01-2008
Castle IS the condition.
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.
Re: frmWarp - stilatore - 15-01-2008
srry but it doesnt work for me
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
Re: frmWarp - Stomach Pulser - 15-01-2008
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)
Re: frmWarp - Matt2 - 15-01-2008
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.
Re: frmWarp - Dr. Spoon - 16-01-2008
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..
Re: frmWarp - Matt2 - 16-01-2008
A case would be easier for multiple destinations.
Re: frmWarp - stilatore - 16-01-2008
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
Re: frmWarp - stilatore - 16-01-2008
i only have this
Code: Case "warpto"
Call PlayerWarp(index, Val(Parse(1)), GetPlayerX(index), GetPlayerY(index))
Exit Sub
Re: frmWarp - Matt2 - 16-01-2008
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.
Re: frmWarp - stilatore - 16-01-2008
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??
Re: frmWarp - Dr. Spoon - 16-01-2008
not exactly
you must change this
Code: If LCase(Parse(0)) = "warpto2" Then
to this
and remove the last
end if
Re: frmWarp - stilatore - 16-01-2008
I get this error: Sub or function not defined
Re: frmWarp - stilatore - 16-01-2008
this is the error
Re: frmWarp - stilatore - 16-01-2008
it doesnt work also without the index.....the problem is the "Call warpto2"
Re: frmWarp - stilatore - 16-01-2008
little help???
Re: frmWarp - Dr. Spoon - 16-01-2008
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
Re: frmWarp - stilatore - 16-01-2008
thaaaaaaaaaaanks!!!!!!!
now it works!!!!
:mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen: :mrgreen:
Re: frmWarp - Matt2 - 16-01-2008
Lol, the newbs.
You can totally change it if you want. I dun care, It took me no longer than 5 minutes.
Re: frmWarp - stilatore - 24-01-2008
and if i want to add a level restriction?? i tried withCode: 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
Re: frmWarp - Anthony - 24-01-2008
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.
Re: frmWarp - stilatore - 24-01-2008
thx
Re: frmWarp - Matt2 - 24-01-2008
stilatore Wrote:and if i want to add a level restriction?? i tried withCode: 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...
|