Page 1 of 1

LAN game for during internship

Posted: 24 Oct 2013 03:38
by dwngrt
Hello dear people again, i am back with a new question :D
I want to create something like this:

Code: Select all

@echo off && cls && title Guess the number [MP]
Setlocal EnableDelayedExpansion
:first
if %user1%==%username% goto login
if %user2%==%username% goto login
if else echo %username%>>gusers.txt
Pause
(
set /p user1=
set /p user2=
)<gusers.txt
Pause
:login
if not %user1%==%username% set player2=%user1%
if not %user2%==%username% set player2=%user2%
cls
Pause
:begin
cls
set usr=
set /p usr=Enter your username:
if {%usr%}=={} goto :begin
set authenticated=
for /f "tokens=*" %%a in (programdata.dll) do (
    if {%%a}=={%usr%} set authenticated=true
)

if not defined authenticated (echo Invalid Username & goto :begin)
Pause
:passwo
echo %time% - %date% Username verified>>log.bak
set pass=
set /p pass=Enter your password:
if {%pass%}=={} goto :begin
set authenticated=
for /f "tokens=*" %%a in (programbase.dll) do (
    if {%%a}=={%pass%} set authenticated=true
)
if not defined authenticated (echo Invalid password & goto :begin)
set current=%usr%
echo %time% - %date% Password verified>>log.bak
Pause
:game
echo Round 1: You \VS/ %player2%
echo.
echo Choose a number between 0 and 11 (so 1 to 10)
echo.
Pause
set /p C=Number1:
echo %C% >number%username%.txt
(
set /p number2=
)<number%player2%.txt
set number1=%C%
ping localhost -n 2 >NUL
cls
echo You draw %number1%
echo %player2% draw %number2%
if %number1%==%number2% set result=draw
if not %number1%==%number2% set result=no one wins
echo.
echo the result: %result%
pause>NUL


This ain't yet finished though, but that's because when i tested it at this stage, it doesn't seem to work.
I sort of guessed some stuff wich i aint sure of it would work.
Anyone a idea how to get this to work?
Thanks in advance!

Re: LAN game for during internship

Posted: 24 Oct 2013 04:12
by ShadowThief
...so what part doesn't work?

Re: LAN game for during internship

Posted: 24 Oct 2013 05:48
by dwngrt
:( as soon as i start the script, it immediately closes again (we all know this i bet :P ) and it goes to fast for me to read where the problem occurs, i added a lot of Pauses in the script but it doesn't help :(

Re: LAN game for during internship

Posted: 24 Oct 2013 06:02
by ShadowThief
change

Code: Select all

if %user1%==%username% goto login
if %user2%==%username% goto login

to

Code: Select all

if "%user1%"=="%username%" goto login
if "%user2%"=="%username%" goto login


and remove the if else in

Code: Select all

if else echo %username%>>gusers.txt


also, change the

Code: Select all

if not %user1%==%username% set player2=%user1%
if not %user2%==%username% set player2=%user2%

to

Code: Select all

if not "%user1%"=="%username%" set player2=%user1%
if not "%user2%"=="%username%" set player2=%user2%



I can't test anything beyond that because I don't have programdata.dll on my computer.

Re: LAN game for during internship

Posted: 24 Oct 2013 06:03
by ShadowThief
Also, I highly recommend running the script from the command prompt instead of double clicking on the file. This way, the window doesn't close when the script stops.