EclipseCommunity Posted February 5, 2011 Author Posted February 5, 2011 Where can I find the code that handles what happens when a player presses enter on an attribute.Do I need to make a new sub routine for it or does one already exist?I'm making an attribute that changes the players sprite when you press enter on the attribute.Thanks. ;)
EclipseCommunity Posted February 5, 2011 Author Posted February 5, 2011 I've copied the code in the client that checks for an item when you press enter. This should work exactly the same for checking if the player is standing on a Mount attribute tile:```Sub CheckMapMount()Dim Buffer As New clsBuffer ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer If GetTickCount > Player(MyIndex).MapGetTimer + 250 Then If Trim$(MyText) = vbNullString Then Player(MyIndex).MapGetTimer = GetTickCount Buffer.WriteLong CMapMount SendData Buffer.ToArray() End If End If Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "CheckMapMount", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```But it's not sending anything to the server like it should be.
Lavos Posted February 6, 2011 Posted February 6, 2011 ~~I can't really get a clear focus on what your trying to do. Is it alright if you can show some screen shots along with some more details?~~Edit : okay after reading it 5 times in a row, i figured your trying to add a spite changer on event on the map editor. There should be on that already exist on the engine but work differently of course, relating to the way you can pick up items. I'd write a new sub for it that might as well work with the door attribute.
EclipseCommunity Posted February 6, 2011 Author Posted February 6, 2011 I have a tile attribute called "Mount".When the player presses enter I want it to check if the player is on a Mount attribute, and if they are, i want it to change their sprite :)
EclipseCommunity Posted February 6, 2011 Author Posted February 6, 2011 I'll give my code…. Might make things easier to understand.In **Sub CheckInputKeys** I have this:```If GetKeyState(vbKeyReturn) < 0 Then CheckMapGetItem CheckMapMount End If```Then this:```Sub CheckMapMount()Dim Buffer As New clsBuffer ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler Set Buffer = New clsBuffer If GetTickCount > Player(MyIndex).MapGetTimer + 250 Then If Trim$(MyText) = vbNullString Then Player(MyIndex).MapGetTimer = GetTickCount Buffer.WriteLong CMapMount SendData Buffer.ToArray() End If End If Set Buffer = Nothing ' Error handler Exit Suberrorhandler: HandleError "CheckMapMount", "modGameLogic", Err.Number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub```That's all for the client, I then gone to the server….I've added **CMapMount** as a variable and also added the following:```HandleDataSub(CMapMount) = GetAddress(AddressOf HandleMapMount)``````Sub HandleMapMount(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Call PlayerMapMount(index)End Sub```Then the sub which handles what should happen when a player Mounts:```Sub PlayerMapMount(ByVal index As Long) Dim i As Long Dim n As Long Dim mapNum As Long Dim Msg As String If Not IsPlaying(index) Then Exit Sub mapNum = GetPlayerMap(index) ' Check that the player is on a Mount attribute tile If Map(GetPlayerMap(index)).Tile(GetPlayerX(index), GetPlayerY(index)).Type <> TILE_TYPE_MOUNT Then Exit Sub Else PlayerMsg index, "Suck my balls", vbWhite End IfEnd Sub```Obviously haven't added the full code to change sprite since I'm trying to get the first part working.When I debug, it seems as though it's not even sending any data to the server from **Sub CheckMapMount**.What am I doing wrong in that sub routine?
Lavos Posted February 6, 2011 Posted February 6, 2011 ~~Give me a moment to figure this out. I'll get back at you on the main forums.~~
Lavos Posted February 6, 2011 Posted February 6, 2011 Have you tried adding CMapMount on modEnum? on both sides?
The New World Posted February 6, 2011 Posted February 6, 2011 Wheres your```Buffer.WriteBytes Data()```?
Lavos Posted February 6, 2011 Posted February 6, 2011 @Yukiyo:> Wheres your```> Buffer.WriteBytes Data()> ```?Well there some things that are missing. I'm just filling the holes for him.
The New World Posted February 6, 2011 Posted February 6, 2011 @Lavos:> Well there some things that are missing. I'm just filling the holes for him.What I'm saying is he didn't include it in HIS code.Which is all kinds of jacked up. Let me download VB6 and I'll try to help.
EclipseCommunity Posted February 6, 2011 Author Posted February 6, 2011 I've just done exactly the same method that is used for checking if an item is on the ground when pressing enter.
The New World Posted February 6, 2011 Posted February 6, 2011 Your Sub CheckMapMount isn't sending any data, only an empty packet. And your HandleMapMount isn't attempting to read any data and process it, all it does is call a sub with no parameters. Why don't you use break points to test if the server is recieving/handling the packet? To use a break point, click on the blank left side of your code and a red circle will appear next to the line, when the program uses that line it'll tell you, and then you know that it's being processed and we can further investigate the issue.
The New World Posted February 7, 2011 Posted February 7, 2011 @Xlithan:> I'm gunna rewrite this.Good idea. Need help, hit me up.
EclipseCommunity Posted February 14, 2011 Author Posted February 14, 2011 Rewrote it. Works great now. Using commands instead of just pressing enter. This allows players to un-mount anywhere on the map also :)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now