Results 1 to 2 of 2

Thread: DB programming question

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    62

    DB programming question

    I have a question. I am currently changing all the variables that store from the DB to just loading straight from the DB. This is a microsoft access DB, EX:

    Grabs from DB, places into a variables, user /saves, stores back into a variable.

    TO

    Grabs striaght from DB for any loading, when player changes something, aka lets say he gains 10 HP, it will save it straight to the DB.

    You can sorta find my old post of what I was doing here: http://www.vbforums.com/showthread.p...09#post2401209

    It' has been going okay for now, but I have a question, for example, a character chats, it must be outputted to the players in the chat room. As of now, the DB stores all the information, like what room he was on. It was easy using the variables, here:
    VB Code:
    1. 'Chat Sub
    2. Private Sub PublicChat(ByVal Index As Integer, Comarray() As String, ComI As Integer)
    3.     Dim i As Integer
    4.    
    5.     'Send to all users in room
    6.     For i = WStcpServer.LBound + 1 To WStcpServer.UBound
    7.         If userroom(i) = userroom(Index) Then 'In the room?
    8.             MsgSend = "~yFrom " & "~w" & users(Index) & "~y: " & Comarray(ComI)
    9.             blnRetVal = WinsockSend(WStcpServer(i), MsgSend)
    10.         Else
    11.         End If
    12.     Next
    13.    
    14. EEnd Sub
    Basicly, it would scan for anyone who was in the room, INDEX being the player who talks, (i) being the search, so any identical matches, it would output, if they were online of course.

    Now, how would this be changed to straight load into the DB? I know of FINDFIRST and such.... The only variable is stored is the username index number for quick calling, since they cannot change it anyways..
    VB Code:
    1. Private Sub PublicChat(ByVal Index As Integer, Comarray() As String, ComI As Integer)
    2.     Dim i As Integer
    3.  
    4.     If Not rsroomdata.EOF Then rsroomdata.MoveFirst ' make sure your on the first one
    5.     rsuserdata.FindFirst "CharacterName='" & username(Index) & "'" 'Find the username ***This will grab the username that is calling it up, so it can get the userroom.
    6.  
    7. userroom = rsuserdata!Room 'User room, I believe.
    8.  
    9.     'Send to all users in room
    10.     For i = WStcpServer.LBound + 1 To WStcpServer.UBound
    11.        [B] If ??? = userroom Then 'How would I search, IN THE ROOM?[/B]
    12.             MsgSend = "~yFrom " & "~w" & rsuserdata!CharacterName & "~y: " & Comarray(ComI)
    13.             blnRetVal = WinsockSend(WStcpServer(i), MsgSend)
    14.         Else
    15.         End If
    16.     Next
    17.    
    18. End Sub
    Basicly, it would have to find all the users with the same room in the DB then output them in the socket, how would this be changed? Any info or help would be grateful!
    Last edited by Hack; May 13th, 2006 at 05:13 AM. Reason: Addedd [vbcode] [/vbcode] tags for more clarity

  2. #2

    Thread Starter
    Member
    Join Date
    Nov 2005
    Posts
    62

    Re: DB programming question

    Basicly it would need to go through the list I believe and find the same room number, though I hope it's quick? Any guides or help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width