vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Fri May 24, 2013 12:58 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Getting spaces to work within chat
PostPosted: Fri Mar 07, 2008 12:06 pm 
Fresh Meat

Joined: Wed Mar 05, 2008 9:33 am
Posts: 17
Alright i came up with

Code:
If GetKey(vbKeySpace) Then
            If IsLegalString(Chr$(KeyAscii)) Then
                ChatBox.InputText = ChatBox.InputText + " "
End If
End If


Which gave me an acward space, but even after that when i send it doesnt show up.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 12:39 pm 
Site Admin

Joined: Fri Jul 14, 2006 4:00 pm
Posts: 11230
Location: Washington
Make a new method, IsLegalChatString(), and use that for the chatting validation instead of IsLegalString(). There is probably a check that is performed somewhere on the client using IsLegalString on chat text, but not positive. Then, in IsLegalChatString(), just add support for missing characters that you can use in the chat.

...

Okay, I decided I'd just write a little guide. I didn't test this, so let me know if it doesn't work or what doesn't work.

Find in the server:

Code:
Private Sub Data_Chat_Say(ByVal inSox As Long)
'*********************************************************************************
'User said something in the local chat
'<Text(S)>
'*********************************************************************************
Dim Text As String

    Text = rBuf.Get_String
   
    'Check if legal
    If Text = vbNullString Then Exit Sub
    If Len(Text) > MAXCHATLENGTH Then Exit Sub
    If Not IsLegalString(Text) Then Exit Sub


Replace with:

Code:
    If Not IsLegalChatString(Text) Then Exit Sub


In the ValidStrings module, add:

Code:
Public Function IsLegalChatString(ByVal s As String) As Boolean
'*********************************************************************************
'Check if a string contains any invalid chat characters
'*********************************************************************************
Dim b() As Byte
Dim i As Long
Dim IsNumeric As Boolean
Dim IsLowerCase As Boolean
Dim IsUpperCase As Boolean

    On Error GoTo ErrOut
   
    'Check for invalid string
    If s = vbNullString Then Exit Function

    'Convert the string into a byte array
    b() = StrConv(s, vbFromUnicode)
   
    'Loop through the string and check the values
    For i = 0 To UBound(b)
        If b(i) < 32 Or b(i) > 126 Then Exit Function
    Next i
       
    'Valid string
    IsLegalChatString = True
   
    Exit Function
   
ErrOut:

    'There was some kind of error :(
    IsLegalChatString = False

End Function


Find in the client:

Code:
    'Text
    Case Else
        If IsEnteringChat Then
            If IsLegalString(Chr$(KeyAscii)) Then
                ChatBox.InputText = ChatBox.InputText & Chr$(KeyAscii)
            End If
        End If


Replace "IsLegalString" with "IsLegalChatString".

That should fix it.


Last edited by Spodi on Fri Mar 07, 2008 2:37 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 12:57 pm 
Fresh Meat

Joined: Wed Mar 05, 2008 9:33 am
Posts: 17
(server)When i try to compile i get
Code:

Public Function IsLegalName(ByVal s As String) As Boolean
'*********************************************************************************
'Check if a string is legal for a name
'*********************************************************************************
   
    'Check the size
    If s = vbNullString Then Exit Function
    If Len(s) > 10 Then Exit Function
    If Len(s) < 3 Then Exit Function
   
    'Check the contents
    If Not IsLegalString(s, True, True, True) Then Exit Function
   
    'All checks out
    IsLegalName = True

End Function


" IsLegalString" is highlighted

Sub Or Function not defined


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 1:34 pm 
Site Admin

Joined: Fri Jul 14, 2006 4:00 pm
Posts: 11230
Location: Washington
Don't delete the method IsLegalString.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 1:46 pm 
Fresh Meat

Joined: Wed Mar 05, 2008 9:33 am
Posts: 17
Spodi wrote:
Don't delete the method IsLegalString.


Omg am an idiot. Sorry xD been home sick so...not thinking clearly.

Ok now i am getting
Code:
    IsLegalString = True


Highlighted from the IsLegalChatString Function

"Function call on left-hand side of assignment must return variant or object"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 2:37 pm 
Site Admin

Joined: Fri Jul 14, 2006 4:00 pm
Posts: 11230
Location: Washington
Change the words "IsLegalString" in "IsLegalChatString" to "IsLegalChatString".


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 07, 2008 3:17 pm 
Fresh Meat

Joined: Wed Mar 05, 2008 9:33 am
Posts: 17
Compiled fine now, logged in... still cant type any spaces...


Top
 Profile  
 
 Post subject: Re: Getting spaces to work within chat
PostPosted: Wed Jun 04, 2008 1:35 pm 
+3 Gloves of Agility

Joined: Fri Aug 04, 2006 4:00 pm
Posts: 163
Location: Canada
Would be good to fix this.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group