Help: XNet

Blitz3D Forums/Blitz3D Programming/Help: XNet

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Can anyone please help me fix:

Graphics 500,600,32,2

SetBuffer (BackBuffer())

XNETConfigServerDialog ("www.c64.feuerware.com","xnet/scripts/hostmanager") 

Global msgz$

Global  Session
Global  Timer		= CreateTimer (30)
Global  Name$;		="No Named"+MilliSecs()								
Global  InputLine$	
Global  LocalObject 
Global  rY =0
Global  NetSession = False ; TRUE FOR REGISTER HOST OR JOIN AVAIBLE XNET-CHATS		

Cls
		
While Not KeyHit(1)

If KeyHit(1) Then Exit : End

Text 10, 10, "Choose nickname:"

AppTitle MilliSecs() Mod 500 < 300

If MilliSecs() Mod 500 < 300 inputline_=inputline+"|" Else inputline_=inputline+"a"

ZControlChat()

Flip

Wend
		
msgz$ = "Logging in to chat.."

Text 10, 30, msgz$

Flip

Port=50001
IP$ ="127.0.0.1"

If NETSESSION=True 

			  XNETGetHostList ()

		While XNETHostFromList () And Session=0

		IP$		=XNETHostIP	 	()
		Port	=XNETHostPort	()
		Info	=XNETHostInfo   ()
				
	Flip
						
		Wend
				
EndIf 

	   Session=XNETJoinSession (IP,Port)	
		
		AppTitle ("CLIENT")

If Not Session
Cls
msgz$ = "Success!"
		AppTitle ("HOST")
	   Session=XNETHostSession  (Port)
		
If NETSESSION=True XNETRegisterHost (Session,"XNET-TEST-CHAT")

Text 10, 10, msgz$

Flip

Delay 1000

EndIf

	Const name_slot=1
Const chat_slot=2
			
	
If Not Session RuntimeError    ("ANYTHING WAS WRONG !!!")		

LocalObject = XNETCreateObject (Session)
	  		  XNETSetString    (LocalObject,name_slot,Name)

							
;___________________________________________________________________________

While Not KeyHit (1)
		
		Cls
		

XNETUpdateSession  (Session)
		
		ControlChat()
		ControlXNET()
		
		Flip 0


WaitTimer (timer)

Wend 

;__________________________________________________________________________________

Function ZControlChat ()
	Local char=GetKey()



		If char

		Select char

			Case 13
						
		If Instr (Mid(Lower(inputline),1,1),inputline)
		
		Return ""
		
		Delete chat.row
		
		EndIf
							
		If Instr (Mid(Lower(inputline),1,3),"ass")
								
			 If Trim(inputline)>"" addline Name+"> "+"***"
			
		EndIf
			
			If Not Instr (Mid(Lower(inputline),1,5),"/nick")
						 
				If Trim (inputline)>"" addline Name+"> "+inputline
				
				Name = inputline
							
;				MSG=XNETCreateMessage 		(LocalObject		  		  )
;					XNETSetString 	  		(MSG,chat_slot,inputline	  )
;					XNETSendSecureMessage   (MSG,0  			  		  )
;
;				Else
;
;			
;				   NEWNAME$ =Trim(Mid (inputline,7))
;				If NEWNAME>""
;				  
;				   inputline= "CHANGED NICK TO "+NEWNAME+">"
;				   ADDLINE NAME+inputline				    
;				   Name=NewName
;				
				EndIf
;				
;				MSG=XNETCreateMessage 		(LocalObject		  		  )
;					XNETSetString 	  		(MSG,chat_slot,inputline	  )
;					XNETSendSecureMessage   (MSG,0  			  		  )
;			
;			
;					XNETSetString 	  		(LocalObject,name_slot,name	  )
;				
;				EndIf 
			
			
				inputline=""
	
	
	
			Case 32
			inputline=inputline+" "
			
	
	
	
			Case 8

			inputline=Mid(inputline,1,Len(inputline)-1)
			
	
	
	
			Default 
	
			inputline=inputline+Trim (Chr(char))
	
			End Select 

		EndIf
		

	        inputline_$=Inputline


  Color 200,200,200

  Rect 2,GraphicsHeight ()-22,GraphicsWidth ()-4,1

  Color 250,250,250

  Text 2,GraphicsHeight ()-20,inputline_


If ry =>  600 chat.row = First row : Delete chat.row 
ry = 2

For chat.row = Each row
If ry<580 Text 2,ry,chat\txt
ry=ry+20

Next

If MilliSecs() Mod 500 < 300 inputline_=inputline+"|" Else inputline_=inputline+""


End Function

Function ControlChat ()
	Local char=GetKey()



		If char

		Select char

			Case 13
						
		If Instr (Mid(Lower(inputline),1,1),inputline)
		
		Return ""
		
		Delete chat.row
		
		EndIf
							
		If Instr (Mid(Lower(inputline),1,3),"ass")
								
			 If Trim(inputline)>"" addline Name+"> "+"***"
			
		EndIf
			
			If Not Instr (Mid(Lower(inputline),1,5),"/nick")
						 
				If Trim (inputline)>"" addline Name+"> "+inputline
							
				MSG=XNETCreateMessage 		(LocalObject		  		  )
					XNETSetString 	  		(MSG,chat_slot,inputline	  )
					XNETSendSecureMessage   (MSG,0  			  		  )

				Else

			
				   NEWNAME$ =Trim(Mid (inputline,7))
				If NEWNAME>""
				  
				   inputline= "CHANGED NICK TO "+NEWNAME+">"
				   ADDLINE NAME+inputline				    
				   Name=NewName
				
				EndIf
				
				MSG=XNETCreateMessage 		(LocalObject		  		  )
					XNETSetString 	  		(MSG,chat_slot,inputline	  )
					XNETSendSecureMessage   (MSG,0  			  		  )
			
			
					XNETSetString 	  		(LocalObject,name_slot,name	  )
				
				EndIf 
			
			
				inputline=""
	
	
	
			Case 32
			inputline=inputline+" "
			
	
	
	
			Case 8

			inputline=Mid(inputline,1,Len(inputline)-1)
			
	
	
	
			Default 
	
			inputline=inputline+Trim (Chr(char))
	
			End Select 

		EndIf
		

	        inputline_$=Inputline


  If MilliSecs() Mod 500 < 300 inputline_=inputline+"|" Else inputline_=inputline+""

  Color 200,200,200

  Rect 2,GraphicsHeight ()-22,GraphicsWidth ()-4,1

  Color 250,250,250

  Text 2,GraphicsHeight ()-20,inputline_


If ry =>  600 chat.row = First row : Delete chat.row 
ry = 2

For chat.row = Each row
If ry<580 Text 2,ry,chat\txt
ry=ry+20

Next



End Function 


Function addLine (txt$)

	If Trim (txt) >""
	Chat.row=New row
	chat\txt=txt
	EndIf 

End Function 

Global Chat.row
		
Type row
Field txt$
End Type 

;__________________________________________________________________________________

Function ControlXnet()


			 XNETGetObjects  (Session)
  				
   			 While XNETCountList    () 

					OBJ=XNETObjectFromList ()
	
				If XNETObjectRemote   (OBJ)
				
					If XNETGetObjectState (Obj) = 1
				
					ADDLINE XNETGetString (obj,name_slot)+" has joined"
				
				EndIf 
	
				EndIf 
					
					 

			 Wend
					
					
						
			 XNETGetMessages (Session)
   				
   			 While XNETCountList    () 

					 Msg	=XNETObjectFromList  (	 )			 
				   Sender	=XNETMessageObject	 (MSG)
					
			 MSGString$		=XNETGetString 		 (Sender,name_slot)+">"
								
			 MSGString =MsgString+ XNETGetString (MSG,chat_slot	   )
			 		 
			 ADDLINE MSGSTRING
	
		     Wend
		


End Function


Basically, I need to press escape and it exits login, chat, and / or program, I also need it to detect cusswords and turn them into *** depending on how many letters there are. for each letter in the cussword, is a * replacement. i need a login at the beginning using mysql. and i need the cursor blinker fixed.

Thanks! :)

Credit to the creator btw :)

~DS~