Wort:    Username:           
 

Tach@all

ich habe einen Chat mit Batch programmiert



Den Code unten speichert ihr als Chat.bat


@echo off

cls
title Batch Chat v1.0 - Locales Chat System by Dome

color 0F



:10

echo Batch Chat v1.0
echo Time:
time /t
echo.
set /p username=Nickname:
if "%username%"=="dein Beliebiger Admin Name" goto pw
if not "%username%"=="dein Beliebiger Admin Name" goto Menue

:pw
set /p Passwort=Password:
if not "%Passwort%"=="dein Beliebiges Passwort" goto exit

:Menue

echo.
echo [1] Server 1
echo [2] Server 2
echo.

set /p choice=Enter Server:
if %choice% == 1 goto 1
if %choice% == 2 goto 2


:1
start server.bat
echo %username% has joined the server >> \\192.168.1.34\Tausch\Chat\Output.txt & time /t >> \\192.168.1.34\Tausch\Chat\Output.txt
:11
cls
color 0A & echo Online

echo Logged in as %username%
echo /help for more informations
set /p input=:
echo %username%: %input% >> \\192.168.1.34\Tausch\Chat\Output.txt
if "%input%"== "/help" goto help >> \\192.168.1.34\Tausch\Chat\Output2.txt
if "%input%"== "/time" time /t >> \\192.168.1.34\Tausch\Chat\Output.txt & time /t
if "%input%"== "/cls" goto pw_cls1

goto 11


:2
start server2.bat
echo %username% has joined the server >> \\192.168.1.34\Tausch\Chat\Output2.txt & time /t >> \\192.168.1.34\Tausch\Chat\Output2.txt
:22
cls
color 0C & echo Online

echo Logged in as %username%
echo /help for more informations
set /p input=:
echo %username%: %input% >> \\192.168.1.34\Tausch\Chat\Output2.txt
if "%input%"== "/help" goto help2 >> \\192.168.1.34\Tausch\Chat\Output2.txt
if "%input%"== "/time" time /t >> \\192.168.1.34\Tausch\Chat\Output2.txt & time /t
if "%input%"== "/cls" goto pw_cls2

goto 22



:pw_cls1
set /p User=Admin:
if not "%User%"=="dein Beliebiger Admin Name" goto exit

set /p Password=Password:
if not "%Password%"=="dein Beliebiges Passwort" goto exit

del Output.txt
echo %User%: Server Restart at >>Output.txt & time /t >>Output.txt
goto :11


:pw_cls2
set /p User=Admin:
if not "%User%"=="dein Beliebiger Admin Name" goto exit

set /p Password=Password:
if not "%Password%"=="dein Beliebiges Passwort" goto exit

del Output2.txt
echo %User%: Server Restart at >>Output2.txt & time /t >>Output2.txt
goto :22

:help2
echo.
echo /time >> \\192.168.1.34\Tausch\Chat\Output2.txt
echo /cls (only Admins) >> \\192.168.1.34\Tausch\Chat\Output2.txt
echo /help >> \\192.168.1.34\Tausch\Chat\Output2.txt
echo /server >> \\192.168.1.34\Tausch\Chat\Output2.txt
echo. >> \\192.168.1.34\Tausch\Chat\Output2.txt
goto 22

:help
echo. >> \\192.168.1.34\Tausch\Chat\Output.txt
echo /time >> \\192.168.1.34\Tausch\Chat\Output.txt
echo /cls (only Admins) >> \\192.168.1.34\Tausch\Chat\Output.txt
echo /help >> \\192.168.1.34\Tausch\Chat\Output.txt
echo /server >> \\192.168.1.34\Tausch\Chat\Output.txt
echo. >> \\192.168.1.34\Tausch\Chat\Output.txt
goto 11





:exit
echo Login fail
goto 10






Den nächsten speichert man als Server.bat




@echo off
title Batch Chat v1.0 - Locales Chat System Server
color 0A

echo Welcome to Server 1
echo Join Server
ping 127.0.0.1 -n 5 >nul
:a

Type \\192.168.1.34\Tausch\Chat\Output.txt
ping 127.0.0.1 -n 2 >nul
cls


goto a



Server 2:
Der nächste Code wird als Server2.bat gespeichert


@echo off
title Batch Chat v1.0 - Locales Chat System Server 2
color 0C

echo Welcome to Server 2
echo Join Server
ping 127.0.0.1 -n 5 >nul
:a

Type \\192.168.1.34\Tausch\Chat\Output2.txt
ping 127.0.0.1 -n 2 >nul
cls


goto a



Jetzt hat man 2 Chatrooms einen in Grün und einer in Rot
Damit die Funktionieren muss man die Daten in einen Ordner schieben, der freigegeben wird und Chat.bat starten.
Bei Vista muss man die Server manuell starten

192.168.1.34 muss man durch die Lokale IP des Server PCS ersetzten

das wars, der Chat geht auch über Hamachi =)

mfg dome94

Edit den Smilie einfach durch : p (zusammenschreiben) ersetzten



QUOTE durch CODE zur besseren Übersichtlichkeit ersetzt.

Nachtrag:

man muss bei der Freigabe Netzwerkbenutzer dürfen Dateien verändern aktiviern sonst geht es nicht

Wenn ihr es getestet habt, dann schreibt bitte eine kurze Antwort (Kritik, Rückmeldung,.....)


Nachricht bearbeitet von dome94 am 12.07.2009 um 17:16:16
Anzeigen

Kann man da noch eine Whisper Funktion hinzufügen?

Ich bekomms einfach nicht hin. Muss man da noch eine Externe Textdatei anlegen, in der alle Namen stehen?
und dann mit

if "%input% == "/whisper %user2%"

die Whisper Funktion schreiben?



Update


Code :
  1. @echo off
  2. cls
  3. title Batch Chat v1.0 - Locales Chat System by Dome
  4. :10
  5. color 0F
  6. cls
  7. echo Batch Chat v1.0
  8. echo Time:
  9. time /t
  10. echo.
  11. set /p username=Nickname:
  12. if "%username%"=="/time" goto time
  13. if "%username%"=="dein Beliebiger Admin Name" goto pw
  14. if "%username%"=="Admin" goto pw
  15. if not "%username%"=="dein Beliebiger Admin Name" goto Menue
  16. if not "%username%"=="dein Beliebiger Admin Name 2" goto Menue
  17. :pw
  18. set /p Passwort=Password:
  19. if not "%Passwort%"=="dein Beliebiges Passwort" goto exit
  20. goto Menue
  21. :time
  22. cls
  23. color 03
  24. time /t
  25. ping 127.0.0.1 -n 5 >nul
  26. cls
  27. goto 10
  28. :Menue
  29. cls
  30. echo.
  31. echo [1] Server 1
  32. echo [2] Server 2
  33. echo.
  34. set /p choice=Enter Server:
  35. if %choice% == 1 goto 1
  36. if %choice% == 2 goto 2
  37. if not %choice% == 1 if not %choice% == 2 goto Menue
  38. :1
  39. start server.bat
  40. echo %username% has joined the server >> \\192.168.1.34\Tausch\Chat\Output.txt & time /t >> \\192.168.1.34\Tausch\Chat\Output.txt
  41. :11
  42. cls
  43. color 0A & echo Online
  44. echo Logged in as %username%
  45. echo /help for more informations
  46. set /p input=:
  47. echo %username%: %input% >> \\192.168.1.34\Tausch\Chat\Output.txt
  48. if "%input%"== "/server" goto server & ping 127.0.0.1 -n 5 >nul
  49. if "%input%"== "/help" goto help
  50. if "%input%"== "/time" time /t >> \\192.168.1.34\Tausch\Chat\Output.txt & time /t
  51. if "%input%"== "/cls" goto pw_cls1
  52. goto 11
  53. :server
  54. if not exist server.bat echo Server 1 offline & goto 99 
  55. echo.
  56. echo Server 1 online
  57. ping 127.0.0.1 -n 2 >nul
  58. :99
  59. if not exist server2.bat echo Server 2 offline & goto 98
  60. echo.
  61. echo Server 2 online
  62. ping 127.0.0.1 -n 5 >nul
  63. :98
  64. goto 11
  65. :2
  66. start server2.bat
  67. echo %username% has joined the server >> \\192.168.1.34\Tausch\Chat\Output2.txt & time /t >> \\192.168.1.34\Tausch\Chat\Output2.txt
  68. :22
  69. cls
  70. color 0C & echo Online
  71. echo Logged in as %username%
  72. echo /help for more informations
  73. set /p input=:
  74. echo %username%: %input% >> \\192.168.1.34\Tausch\Chat\Output2.txt
  75. if "%input%"== "/server" goto server1 & ping 127.0.0.1 -n 5 >nul
  76. if "%input%"== "/help" goto help2
  77. if "%input%"== "/time" time /t >> \\192.168.1.34\Tausch\Chat\Output2.txt & time /t
  78. if "%input%"== "/cls" goto pw_cls2
  79. goto 22
  80. :server1
  81. if not exist server.bat echo Server 1 offline & goto 99 
  82. echo.
  83. echo Server 1 online
  84. ping 127.0.0.1 -n 2 >nul
  85. :99
  86. if not exist server2.bat echo Server 2 offline & goto 98
  87. echo.
  88. echo Server 2 online
  89. ping 127.0.0.1 -n 5 >nul
  90. :98
  91. goto 22
  92. :pw_cls1
  93. set /p User=Admin:
  94. if not "%User%"=="dein Beliebiger Admin Name" goto exit
  95. :100
  96. set /p Password=Password:
  97. if not "%Password%"=="dein Beliebiges Passwort" goto exit
  98. del Output.txt
  99. echo %User%: Server Restart at >>Output.txt & time /t >>Output.txt
  100. goto :11
  101. :pw_cls2
  102. set /p User=Admin:
  103. if not "%User%"=="dein Beliebiger Admin Name" goto exit
  104. :101
  105. set /p Password=Password:
  106. if not "%Password%"=="dein Beliebiges Passwort" goto exit
  107. del Output2.txt
  108. echo %User%: Server Restart at >>Output2.txt & time /t >>Output2.txt
  109. goto :22
  110. :help2
  111. echo.
  112. echo /time
  113. echo /cls (only Admins)
  114. echo /help
  115. echo /server
  116. echo Any problems? Contact the admin: dome1994@googlemail.com
  117. echo.
  118. ping 127.0.0.1 -n 10 >nul
  119. goto 22
  120. :help
  121. echo.
  122. echo /time
  123. echo /cls (only Admins)
  124. echo /help
  125. echo /server
  126. echo Any problems? Contact the admin: dome1994@googlemail.com
  127. echo.
  128. ping 127.0.0.1 -n 10 >nul
  129. goto 11
  130. :exit
  131. cls
  132. color 0E
  133. echo Login fail
  134. echo Wait 5 Seconds
  135. ping 127.0.0.1 -n 5 >nul
  136. color 0F
  137. cls
  138. goto 10


Nachricht bearbeitet von dome94 am 10.09.2009 um 22:46:18
Antworten dome94
Tom's Hardware > Foren > Eigene Website, Hosting, Webdesign, Programmieren > Batch Chat
Zu:

Es gibt 64 identifizierte und nicht identifizierte User. Zur Ansicht der Liste identifizierter User, Hier klicken.

Google Anzeigen
  • Die Community jetzt fragen
  • Veröffentlichen
Anzeige
Die folgenden Community-Mitglieder erhielten Auszeichnungen!
Wir gratulieren:
Anzeigen