2
我正在爲我的兄弟工作在網絡上的迷你口袋妖怪遊戲。 不幸的是,在測試時,我發現出於某種原因,它只在嘗試向另一臺計算機發送字符串的行上出現「錯誤的文件名或數字」錯誤,但在循環接收命令時沒有錯誤。在QB64中通過網絡接收和發送字符串
這裏是我的代碼:
SCREEN 12
CLS
PRINT ""
PRINT ""
PRINT ""
PRINT ""
PRINT ""
PRINT " POKELITE - By Mark "
PRINT ""
PRINT ""
INPUT "Join or Host a game? ", hostorjoin$
hostorjoin$ = UCASE$(hostorjoin$)
IF hostorjoin$ = "JOIN" THEN GOTO JOIN
IF hostorjoin$ = "HOST" THEN GOTO HOST
HOST:
server& = _OPENHOST("TCP/IP:300")
PRINT "Waiting for connection..."
PRINT "! Remember: If playing locally, give the other player your IPv4 Address !"
DO
HOST& = _OPENCONNECTION(server&)
LOOP UNTIL HOST& <> 0
PRINT ""
PRINT "2nd Player Joined!"
SLEEP 2
GOTO GAME
JOIN:
INPUT "Enter Server IPv4 Address (Example: 192.168.1.25): ", joinip$
handle& = _OPENCLIENT("TCP/IP:300:" + joinip$)
IF handle& = 0 THEN PRINT "Connection failed!": SLEEP 2: CLS: GOTO JOIN
GOTO GAME
GAME:
CLS
INPUT "Enter your name: ", name$
IF name$ = "" THEN GOTO GAME
PRINT "Waiting for other player..."
IF hostorjoin$ = "JOIN" THEN
PUT HOST&, , name$
DO
GET handle&, , name2$
LOOP UNTIL name2$ <> ""
END IF
IF hostorjoin$ = "HOST" THEN
PUT handle&, , name$
DO
GET HOST&, , name2$
LOOP UNTIL name2$ <> ""
END IF
PRINT name$
PRINT name2$