|
-
May 13th, 2006, 01:50 AM
#1
Thread Starter
Member
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:
'Chat Sub
Private Sub PublicChat(ByVal Index As Integer, Comarray() As String, ComI As Integer)
Dim i As Integer
'Send to all users in room
For i = WStcpServer.LBound + 1 To WStcpServer.UBound
If userroom(i) = userroom(Index) Then 'In the room?
MsgSend = "~yFrom " & "~w" & users(Index) & "~y: " & Comarray(ComI)
blnRetVal = WinsockSend(WStcpServer(i), MsgSend)
Else
End If
Next
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:
Private Sub PublicChat(ByVal Index As Integer, Comarray() As String, ComI As Integer)
Dim i As Integer
If Not rsroomdata.EOF Then rsroomdata.MoveFirst ' make sure your on the first one
rsuserdata.FindFirst "CharacterName='" & username(Index) & "'" 'Find the username ***This will grab the username that is calling it up, so it can get the userroom.
userroom = rsuserdata!Room 'User room, I believe.
'Send to all users in room
For i = WStcpServer.LBound + 1 To WStcpServer.UBound
[B] If ??? = userroom Then 'How would I search, IN THE ROOM?[/B]
MsgSend = "~yFrom " & "~w" & rsuserdata!CharacterName & "~y: " & Comarray(ComI)
blnRetVal = WinsockSend(WStcpServer(i), MsgSend)
Else
End If
Next
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
-
May 13th, 2006, 09:46 AM
#2
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|