seifistration bug

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • public OnPlayerCommandText(playerid, cmdtext[])
    {
    new cmd[256],tmp[256],idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp(cmd, "/register", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(AccountInfo[playerid][aLogged] == 1)
    {
    SendClientMessage(playerid, RED, "You are already logged in.");
    return 1;
    }
    new sendername[MAX_PLAYER_NAME],string[128];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), ACCOUNTS_FOLDER, sendername);
    new File: hFile = fopen(string, io_read);
    if (hFile)
    {
    SendClientMessage(playerid, RED, "That name is already taken. Please reconnect using a different username.");
    fclose(hFile);
    return 1;
    }
    new tmppass[128];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, ORANGE, "USAGE: /register [password]");
    return 1;
    }
    strmid(tmppass, tmp, 0, strlen(cmdtext), 255);
    Encrypt(tmppass);
    OnPlayerRegister(playerid,tmppass);
    }
    return 1;
    }
    return 0;
    }
    public ShowLoginMenu(playerid)
    {
    TextDrawShowForPlayer(playerid, Nick);
    TextDrawShowForPlayer(playerid, Password);
    TextDrawShowForPlayer(playerid, Login);
    TextDrawShowForPlayer(playerid, BottomMsg[playerid]);
    TextDrawShowForPlayer(playerid, Name[playerid]);
    TextDrawShowForPlayer(playerid, Pass[playerid]);
    }


    public HideLoginMenu(playerid)
    {
    TextDrawHideForPlayer(playerid, Nick);
    TextDrawHideForPlayer(playerid, Password);
    TextDrawHideForPlayer(playerid, Login);
    TextDrawHideForPlayer(playerid, BottomMsg[playerid]);
    TextDrawHideForPlayer(playerid, Name[playerid]);
    TextDrawHideForPlayer(playerid, Pass[playerid]);
    }


    stock strtok(const string[], &index,seperator=' ')
    {
    new length = strlen(string);
    new offset = index;
    new result[128];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
    result[index - offset] = string[index];
    index++;
    }


    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
    index++;
    }
    return result;
    }
    stock ini_GetKey( line[] )
    {
    new keyRes[256];
    keyRes[0] = 0;
    if ( strfind( line , "=" , true ) == -1 ) return keyRes;
    strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
    return keyRes;
    }


    stock ini_GetValue( line[] )
    {
    new valRes[256];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
    }
    public OnPlayerRegister(playerid, password[])
    {
    if(IsPlayerConnected(playerid))
    {
    new player[MAX_PLAYER_NAME];
    GetPlayerName(playerid, player, 50);
    new string3[32];
    new playername3[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername3, sizeof(playername3));
    format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
    new ip[20];
    GetPlayerIp(playerid,ip,sizeof(ip));
    new File: hFile = fopen(string3, io_write);
    if (hFile)
    {
    strmid(AccountInfo[playerid][aPassword], password, 0, strlen(password), 255);
    new var[128];
    format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
    format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
    fclose(hFile);
    SendClientMessage(playerid, GREEN, "|- Account successfully registered. You may now login. -|");
    TextDrawSetString(Name[playerid], playername3);
    TextDrawSetString(Pass[playerid], "l");
    ShowLoginMenu(playerid);
    MenuShown[playerid] = 1;
    TogglePlayerControllable(playerid, false);
    TextDrawSetString(BottomMsg[playerid], "Enter your password");
    }
    }
    return 1;
    }


    public OnPlayerUpdate(playerid)
    {
    if(IsPlayerConnected(playerid))
    {
    if(AccountInfo[playerid][aLogged] == 1)
    {
    new string3[128];
    new playername3[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername3, sizeof(playername3));
    format(string3, sizeof(string3), ACCOUNTS_FOLDER, playername3);
    new ip[20];
    GetPlayerIp(playerid,ip,sizeof(ip));
    new File: hFile = fopen(string3, io_write);
    if (hFile)
    {
    new var[128];
    format(var, 128, "Password=%s\n", AccountInfo[playerid][aPassword]);fwrite(hFile, var);
    format(var, 128, "IP=%s\n",ip);fwrite(hFile, var);
    fclose(hFile);
    }
    }
    }
    return 1;
    }


    public OnPlayerLogin(playerid,password[])
    {
    // new tmp2[256];
    new string2[128];
    new playername2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername2, sizeof(playername2));
    format(string2, sizeof(string2), ACCOUNTS_FOLDER, playername2);
    new File: UserFile = fopen(string2, io_read);
    if ( UserFile )
    {
    new PassData[256];
    new keytmp[256], valtmp[256];
    fread( UserFile , PassData , sizeof( PassData ) );
    keytmp = ini_GetKey( PassData );
    if( strcmp( keytmp , "Password" , true ) == 0 )
    {
    valtmp = ini_GetValue( PassData );
    strmid(AccountInfo[playerid][aPassword], valtmp, 0, strlen(valtmp)-1, 255);
    }
    if(strcmp(AccountInfo[playerid][aPassword],password, true ) == 0 )
    {
    for(new p = 0; p < strlen(AccountInfo[playerid][aPassword]); p++)
    {
    password[p] = '?';
    }
    TextDrawSetString(Pass[playerid], password);
    TextDrawSetString(BottomMsg[playerid], "~g~You are now logging in...");
    SetTimerEx("LogIn", LOGIN_DELAY*1000, 0, "d", playerid);
    printf("%s is logging in...",playername2);
    new key[256] ;
    new Data[256];
    while ( fread( UserFile , Data , sizeof( Data ) ) )
    {
    key = ini_GetKey( Data );
    /*if(strcmp(key, "AdminLevel", true) == 0) // This is only an example if you want to add more stuff to store in a file.
    {
    val = ini_GetValue( Data );
    AccountInfo[playerid][AdminLevel] = strval(val); // Uncommenting this will give you errors if the variable isn't defined.
    }*/
    }
    fclose(UserFile);


    }
    else
    {
    TextDrawSetString(BottomMsg[playerid], "~r~Invalid Password");
    fclose(UserFile);
    return 0;
    }
    }
    return 0;
    }


    public LogIn(playerid)
    {
    AccountInfo[playerid][aLogged] = 1;
    HideLoginMenu(playerid);
    TogglePlayerControllable(playerid, true);
    MenuShown[playerid] = 0;
    }


    Encrypt(string[])
    {
    for(new x=0; x < strlen(string); x++)
    {
    string[x] += (3^x) * (x % 15);
    if(string[x] > (0xff))
    {
    string[x] -= 256;
    }
    }
    }


    ich kann mich nicht registrieren, was ist hier falsch wenn die dialog box erscheint kann ich nichts eingeben

    Einmal editiert, zuletzt von Optiimal ()

  • Zum einen ist das FS Seifistration für 0.2x.
    Zum anderen währe es vielleicht sinnvoller wenn du das im englishen Forum den Seif selber fragst.


    Wenn du dir den Ersten Post von dem Thread im englishen Forum mal anschaust wirst du einen Link zu einer 0.3 kompatiblen variante finden.
    Die funktioniert auch ohne nennenswerte probleme.

    Goth's:

    • Don't always wear black
    • Don't workship satan
    • Are not evil
    • Do not hate everybody
    • Are not always depressed
    • Can be happy too
    • Are usually nice people
    • Are normal, just like you