Mirage Source http://www.miragesource.net/forums/ |
|
frmWarp http://www.miragesource.net/forums/viewtopic.php?f=201&t=3277 |
Page 1 of 4 |
Author: | stilatore [ Tue Jan 15, 2008 1:06 pm ] |
Post subject: | frmWarp |
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 |
Author: | Matt2 [ Tue Jan 15, 2008 1:26 pm ] |
Post subject: | Re: frmWarp |
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 <Condition> Then <Effect 1> <Effect 2> Else <Effect 3> <Effect 4? End if So, if you set it up like that, I believe the warping code[client side] is... Code: Call PlayerWarp(MyIndex, MapNum, X, Y) I'm in class, so, I can't check. |
Author: | stilatore [ Tue Jan 15, 2008 3:16 pm ] |
Post subject: | Re: frmWarp |
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?? |
Author: | Matt2 [ Tue Jan 15, 2008 5:23 pm ] |
Post subject: | Re: frmWarp |
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. |
Author: | stilatore [ Tue Jan 15, 2008 6:39 pm ] |
Post subject: | Re: frmWarp |
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 |
Author: | Stomach Pulser [ Tue Jan 15, 2008 10:31 pm ] |
Post subject: | Re: frmWarp |
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)
|
Author: | Matt2 [ Tue Jan 15, 2008 10:32 pm ] |
Post subject: | Re: frmWarp |
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. |
Author: | Dr. Spoon [ Wed Jan 16, 2008 4:48 pm ] |
Post subject: | Re: frmWarp |
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.. |
Author: | Matt2 [ Wed Jan 16, 2008 5:35 pm ] |
Post subject: | Re: frmWarp |
A case would be easier for multiple destinations. |
Author: | stilatore [ Wed Jan 16, 2008 6:38 pm ] |
Post subject: | Re: frmWarp |
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 |
Author: | stilatore [ Wed Jan 16, 2008 6:39 pm ] |
Post subject: | Re: frmWarp |
i only have this Code: Case "warpto"
Call PlayerWarp(index, Val(Parse(1)), GetPlayerX(index), GetPlayerY(index)) Exit Sub |
Author: | Matt2 [ Wed Jan 16, 2008 6:40 pm ] |
Post subject: | Re: frmWarp |
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. |
Author: | stilatore [ Wed Jan 16, 2008 6:52 pm ] |
Post subject: | Re: frmWarp |
so i have simply to put your code Code: ' ::::::::::::::::::::::::::::::::: in the server under ' :: 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 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?? |
Author: | Dr. Spoon [ Wed Jan 16, 2008 8:16 pm ] |
Post subject: | Re: frmWarp |
not exactly you must change this Code: If LCase(Parse(0)) = "warpto2" Then to this Code: Case "warpto2" and remove the last end if |
Author: | stilatore [ Wed Jan 16, 2008 8:31 pm ] |
Post subject: | Re: frmWarp |
I get this error: Sub or function not defined |
Author: | Lea [ Wed Jan 16, 2008 8:42 pm ] |
Post subject: | Re: frmWarp |
So which sub or function is undefined? Define it. |
Author: | stilatore [ Wed Jan 16, 2008 8:46 pm ] | ||
Post subject: | Re: frmWarp | ||
this is the error
|
Author: | Lea [ Wed Jan 16, 2008 8:50 pm ] |
Post subject: | Re: frmWarp |
Then you never defined the sub. Matt wrote it above, but your arguements are different than his anyways (his does not have an index) so maybe check with him to see if it needs it or not. |
Author: | stilatore [ Wed Jan 16, 2008 9:00 pm ] |
Post subject: | Re: frmWarp |
it doesnt work also without the index.....the problem is the "Call warpto2" |
Author: | Lea [ Wed Jan 16, 2008 9:16 pm ] |
Post subject: | Re: frmWarp |
obviously, it doesn't work with the index, either You need to define the function, and modify Matt's to work with the index value. |
Author: | stilatore [ Wed Jan 16, 2008 9:24 pm ] |
Post subject: | Re: frmWarp |
little help??? |
Author: | Dr. Spoon [ Wed Jan 16, 2008 9:27 pm ] |
Post subject: | Re: frmWarp |
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 |
Author: | stilatore [ Wed Jan 16, 2008 9:59 pm ] |
Post subject: | Re: frmWarp |
thaaaaaaaaaaanks!!!!!!! now it works!!!! |
Author: | Lea [ Wed Jan 16, 2008 11:14 pm ] |
Post subject: | Re: frmWarp |
I only had to hint at it a few times ;-; |
Author: | Matt2 [ Wed Jan 16, 2008 11:17 pm ] |
Post subject: | Re: frmWarp |
Lol, the newbs. You can totally change it if you want. I dun care, It took me no longer than 5 minutes. |
Page 1 of 4 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |