13-09-2010, 12:01 PM
(Questo messaggio è stato modificato l'ultima volta il: 13-09-2010, 01:08 PM da Jonathan Archer.)
Avevo in progetto di realizzare un gioco ma sto trovando difficoltà ad hostare/joinare alla partita. Il fatto è che io uso il protocollo TCP/IP che dovrebbe funzionare con internet se non erro? Può essere che sbaglio qualcosa oppure xk sono collegato a internet in wifi? Il Firewall è disattivato
Codice Host:
[SPOILER]Endfunction[/SPOILER]
Codice Client:
[SPOILER][/SPOILER]
Ovviamente ho fatto pure in modo che si potesse inserire manualmente l'ip del proprio host/client. A voi la parola ora
Codice Host:
[SPOILER]
Codice PHP:
Startserver(TCPIPCheck())
Disable escapekey
Do
REM TERMINA SESSIONE SE VIENE PREMUTO ESC
If escapekey()=1
Free net game
Print "Server siession terminated. Press any key to exit"
Suspend for key
end
Endif
Loop
Function TCPIPCheck()
Print "Performing network connections checklist" : wait 50
Perform checklist for net connections
If checklist quantity()=0
Print "Error: No network options avaible"
Print "Press any key to End"
Wait key
Endif
Print "Checklist completed, checking list for TCP/IP"
Netoption$ = "Error"
For x=1 to checklist quantity()
If checklist string$(x)="Internet TCP/IP Connection for Directplay"
NetOption$=str$(x)
Endif
Next x
If netOption$="Error"
Print "Sorry, TCP/IP is not availible"
Wait key
End
Else
Print "Checklist check complete, TCP/IP is availible at slow number "+NetOption$
Endif
Endfunction NetOption$
Function StartServer(Newoption$)
Print "Setting Network Connection"
Set Net Connection val(NewOption$), "127.0.0.1"
Print "Starting Server..."
Create Net Game "My Test Server","Host",2,2
Codice Client:
[SPOILER]
Codice PHP:
IpAdd$="127.0.0.1"
Netlist$="Error"
Print "Scanning for network connections"
Wait 50
Perform checklist for net connections
Print "Scanning for TCP/IP Connection"
For index=1 to checklist quantity()
If checklist string$(Index)="Internet TCP/IP Connection For DirectPlay"
Netlist$=str$(Index)
Endif
Next index
If Netlist$="Error"
Print "Scanning complete. TPC/IP not availible"
Wait key
End
Else
Print "Scanning Complete. TPC/IP is availible, proceding with host scan"
Endif
wait 50
Print "Searching for Server on ",IPAdd$
Print "Plese Wait..."
Sleep 50
Set net connection val(Netlist$), IPAdd$
Perform checklist for net sessions
If checklist Quantity()=0
Print "No Server detect, please ensure it is running, and that you're setup firewalls are setup correctly"
Print "Press any key to exit"
Wait key
End
Endif
Print "The following servers where detected, please select the server to join"
For x=1 to checklist quantity()
Print str$(x)+". "+Checklist string$(x)
Next x
Repeat
Print
Input "Enter you selection: ",Server$
If val(Server$)<0 or val(Server$)>Checklist quantity()
Print "That is not a valid choice, please select on of the options above"
Endif
Until val(Server$)>0 and val(Server$)<=Checklist quantity()
Print "Connecting to "+Checklist string$(val(Server$));"..."
Sleep 50
Join net game val(Server$),"Client"
wait 50
If Net game exists()=1 then Print "Connection sucessful. PRess any key to quit Client." : Else : Print "Connection wasn't established, press any key yo quit"
wait 50
Free Net Game
End
Ovviamente ho fatto pure in modo che si potesse inserire manualmente l'ip del proprio host/client. A voi la parola ora