Mein Register- und Loginsystem funktioniert nicht.
Der Name wird unter "scriptfiles" richtig eingetragen, jedoch stimmt das Passwort, welches darin gespeichert wird nicht (die restlichen Informationen stimmen).
Wenn ich mich registrieren, dann das Passwort eingebe, um mich einzuloggen, werde ich immer eingeloggt, obwohl das Passwort auch falsch sein könnte.
Wo liegt das Problem?
Hier mal der Code von OnPlayerText:
public OnPlayerText(playerid, text[])
{
if(gRegistered == 0)
{
if(gLogged == 0)
{
format(Temparray, sizeof(Temparray), "%s.ini", PlayerInfo[playerid][pName]);
new File: UserFile = fopen(Temparray, io_read);
if(UserFile)
{
TextDrawSetString(TTemp, "~>~~n~~>~~n~~>~~n~~n~~>~~w~Benutzername wird bereits~n~~>~~w~verwendet!~n~~>~");
SendClientMessage(playerid, COLOR_GRAD1, "Benutzername wird bereits verwendet!");
fclose(UserFile);
return 1;
}
new tmppass[64];
Temparray = strtok(text, idx);
strmid(tmppass, Temparray, 0, strlen(text), 255);
Secure(tmppass);
pRegister(playerid, tmppass);
return 1;
}
else
{
TextDrawSetString(TTemp, "~>~~n~~>~~n~~>~~n~~n~~>~~w~Bereits eingeloggt~n~~>~~n~~>~");
SendClientMessage(playerid, COLOR_GRAD1, "Bereits eingeloggt!");
}
return 1;
}
if(gRegistered == 1)
{
if(gLogged == 0)
{
new tmppass[64];
Temparray = strtok(text, idx);
strmid(tmppass, Temparray, 0, strlen(text), 255);
Secure(tmppass);
pLogin(playerid, tmppass);
}
else
{
TextDrawSetString(TTemp, "~>~~n~~>~~n~~>~~n~~n~~>~~w~Du bist bereits eingeloggt!~n~~>~~n~~>~");
SendClientMessage(playerid, COLOR_GRAD1, "Du bist bereits eingeloggt!");
}
return 1;
}
return 1;
}
Dann noch pRegister und pLogin:
public pRegister(playerid, pass[])
{
PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
new var[32];
PlayerInfo[playerid][pRegistered] = 1;
gRegistered = 1;
gLogged = 0;
format(Temparray, sizeof(Temparray), "%s.ini", PlayerInfo[playerid][pName]);
new File: UserFile = fopen(Temparray, io_write);
if(UserFile)
{
strmid(PlayerInfo[playerid][pPass], pass, 0, strlen(pass), 255);
format(var, 32, "Pass=%s\n", PlayerInfo[playerid][pPass]);fwrite(UserFile, var);
format(var, 32, "Level=%d\n", PlayerInfo[playerid][pLevel]);fwrite(UserFile, var);
format(var, 32, "AdminLevel=%d\n", PlayerInfo[playerid][pAdminLevel]);fwrite(UserFile, var);
format(var, 32, "Deaths=%d\n", PlayerInfo[playerid][pDeaths]);fwrite(UserFile, var);
format(var, 32, "Kills=%d\n", PlayerInfo[playerid][pKills]);fwrite(UserFile, var);
format(var, 32, "Registered=%d\n", PlayerInfo[playerid][pRegistered]);fwrite(UserFile, var);
format(var, 32, "Money=%d\n", PlayerInfo[playerid][pRegistered]);fwrite(UserFile, var);
fclose(UserFile);
}
TextDrawSetString(TTemp, "~>~~n~~>~~n~~>~~n~~n~~>~~w~Account registriert!~n~~>~~w~Gib dein Passwort ein~n~~>~");
SendClientMessage(playerid, COLOR_YELLOW, "Account registriert, gib dein Passwort ein!");
return 1;
}
public pLogin(playerid, pass[])
{
format(Temparray, sizeof(Temparray), "%s.ini", PlayerInfo[playerid][pName]);
new File: UserFile = fopen(Temparray, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pPass], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pPass],pass, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Level" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pLevel] = strval( val ); }
if( strcmp( key , "AdminLevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdminLevel] = strval( val ); }
if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
if( strcmp( key , "Registered" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pRegistered] = strval( val ); }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pMoney] = strval( val ); }
}//end while
fclose(UserFile);//close the file after everything has been read in the while
gLogged = 1;
TextDrawSetString(TTemp, "~>~~n~~>~~n~~>~~n~~n~~>~~w~Erfolgreich eingeloggt!~n~~>~~n~~>~");
SendClientMessage(playerid, COLOR_YELLOW, "Erfolgreich eingeloggt!");
if(PlayerInfo[playerid][pName] == SuperAdmin[playerid])
{
Temparray = "~w~Welcome ~l~H ~y~u ~l~N ~y~7 ~l~3 ~y~r";
GameTextForAll(Temparray, 5000, 4);
TTemp2 = TextDrawCreate(250.00, 250.00, "~w~Welcome ~l~H ~y~u ~l~N ~y~7 ~l~3 ~y~r");
TextDrawAlignment(TTemp2, 0);
TextDrawFont(TTemp2, 1);
TextDrawUseBox(TTemp2, 0);
TextDrawLetterSize(TTemp2, 0.299999, 1.300000);
TextDrawSetOutline(TTemp2, 0);
TextDrawSetProportional(TTemp2, 1);
TextDrawShowForAll(TTemp2);
SetTimer("DestroyWelcome", 5000, 0);
}
return 1;
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: Falsches Passwort.");
fclose(UserFile);
return 1;
}
}
return 1;
}
Ich weiss nicht mehr weiter...