Beiträge von relyyy

    Hab schon viel ausprobiert. Aber entweder stimmt garkein PW oder es gehen alle -.-*


    Habs jetzt hinbekommen, das wenn mein PW 123 ist, das wenn man ein falsches PW eingibt, dann die Meldung kommt. Ist auch richtig. Aber wenn ich 1234 angebe, komme ich trotzdem rein. Hoffe ihr versteht es^^


    Oh man, habs hinbekommen ;)





    Na toll. Alles funzt. Auch nach rcon gmx. Aber wenn ich die konsole schließe und wieder öffne, kann man wieder mit jedem Passwort rein :(


    __________________________________________________________________________________________________________________________________________________________________
    So jetzt funzt alles, mit kleiner Hilfe von 8d. :)


    Bei den Defines:
    #define Weiß 0xFFFFFFAA
    #define Hellblau 0x33CCFFAA
    #define rot 0xAA3333AA

    Bei den Forwards:
    forward OnPlayerUpdate(playerid);
    forward Encrypt(string[]);
    forward Einloggen(playerid,password[]);
    Bei den News:
    new PlayerInfo[MAX_PLAYERS][pInfo];
    new gPlayerLogged[MAX_PLAYERS];
    new gPlayerAccount[MAX_PLAYERS];


    enum pInfo
    {
    pPassword[128],
    pAdmin,
    pKills,
    pDeaths,
    pCash,
    };


    OnPlayerConnect:
    public OnPlayerConnect(playerid)
    {
    new Spieler[MAX_PLAYER_NAME];
    new Text[128];
    GetPlayerName(playerid, Spieler, sizeof(Spieler));
    format(Text, sizeof(Text), "%s.cer", Spieler);
    if(fexist(Text))
    {
    gPlayerAccount[playerid] = 1;
    SendClientMessage(playerid, COLOR_YELLOW, "Du bist bereits registriert, benutze /login [password]");
    return 1;
    }
    else
    {
    gPlayerAccount[playerid] = 0;
    SendClientMessage(playerid, COLOR_YELLOW, "Du bist noch nicht registriert, benutze /register [password]");
    }
    return 1;
    }



    OnPlayerDisconnect:
    public OnPlayerDisconnect(playerid, reason)
    {

    OnPlayerUpdate(playerid);
    gPlayerLogged[playerid] = 0;
    return 1;
    }


    OnPlayerDeath:
    public OnPlayerDeath(playerid, killerid, reason)
    {
    PlayerInfo[playerid][pDeaths] += 1;
    GivePlayerMoney(killerid,300);
    new score = GetPlayerScore(playerid);
    SetPlayerScore(killerid, score+1);
    PlayerInfo[killerid][pKills] +=1;
    return 1;
    }


    OnPlayerCommandText:
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new cmd[128];
    new idx;
    cmd = strtok(cmdtext, idx);
    new tmp[128];
    new playername[MAX_PLAYER_NAME];
    if (strcmp(cmd, "/einloggen", true) ==0 )
    {
    if(IsPlayerConnected(playerid))
    {
    new pass[64];
    if(gPlayerLogged[playerid] == 1)
    {
    SendClientMessage(playerid, rot, "Du bist bereits eingeloggt!");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, Grau, "Benutze: /login [password]");
    return 1;
    }
    strmid(pass, tmp, 0, strlen(cmdtext), 255);
    Encrypt(pass);
    Einloggen(playerid,pass);
    }
    return 1;
    }
    if (strcmp(cmd, "/erstellen", true)==0)
    {
    new string[128];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, Grau, "Benutze: /erstellen [Passwort]");
    return 1;
    }
    if (gPlayerAccount[playerid] == 1)
    {
    SendClientMessage(playerid, rot, "Der Account ist schon registriert!");
    return 1;
    }


    strmid(PlayerInfo[playerid][pPassword], tmp, 0, strlen(cmdtext), 255);
    Encrypt(PlayerInfo[playerid][pPassword]);
    GetPlayerName(playerid, playername, sizeof(playername));
    format(string, sizeof(string), "/Spieler/%s.ini", playername);
    new File: file = fopen(string, io_read);
    if (file)
    {
    SendClientMessage(playerid, rot, "Der Account ist schon registriert!");
    fclose(file);
    return 1;
    }
    new File:hFile;
    hFile = fopen(string, io_append);
    new var[32];//
    format(var, 32, "Passwort=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
    format(var, 32, "Morde=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
    format(var, 32, "Tode=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
    PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
    format(var, 32, "Geld=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
    fclose(hFile);
    Einloggen(playerid,PlayerInfo[playerid][pPassword]);
    return 1;
    }
    return 0;
    }


    Einloggen:
    public Einloggen(playerid,password[])
    {
    new name2[MAX_PLAYER_NAME];
    new string2[64];
    GetPlayerName(playerid, name2, sizeof(name2));
    format(string2, sizeof(string2), "/Spieler/%s.ini", name2);
    new File: UserFile = fopen(string2, io_read);
    if (UserFile)
    {
    new PassData[256];
    new valtmp[256], keytmp[256];
    fread( UserFile , PassData , sizeof( PassData ) );
    keytmp = ini_GetKey( PassData );
    if( strcmp( keytmp , "Passwort" , true ) == 0 )
    {
    valtmp = ini_GetValue( PassData );
    strmid(PlayerInfo[playerid][pPassword], valtmp, 0, strlen(valtmp)-1, 255);
    }
    if (strcmp(PlayerInfo[playerid][pPassword], password, true) == 0)
    {
    new key[ 256 ],val[ 256 ];
    new Data[ 256 ];
    while ( fread( UserFile , Data , sizeof( Data ) ) )
    {
    key = ini_GetKey( Data );
    if( strcmp( key , "Adminlevel" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAdmin] = strval( val ); }
    if( strcmp( key , "Morde" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
    if( strcmp( key , "Tode" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
    if( strcmp( key , "Geld" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
    }
    fclose(UserFile);
    gPlayerLogged[playerid] = 1;
    gPlayerAccount[playerid] = 1;
    GetPlayerName(playerid, name2, sizeof(name2));
    format(string2, sizeof(string2), "Willkommen %s, du hast dich erfolgreich eingeloggt!", name2);
    SendClientMessage(playerid, Weiß,string2);
    SpawnPlayer(playerid);
    }
    else
    {
    SendClientMessage(playerid, rot, "Das Passwort ist falsch!");
    fclose(UserFile);
    }
    }
    return 1;
    }


    OnPlayerUpdate:
    public OnPlayerUpdate(playerid)
    {
    if(IsPlayerConnected(playerid))
    {
    if(gPlayerLogged[playerid])
    {
    new string3[32];
    new pname3[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname3, sizeof(pname3));
    format(string3, sizeof(string3), "/Spieler/%s.ini", pname3);
    new File: hFile = fopen(string3, io_write);
    if (hFile)
    {
    new var[32];
    format(var, 32, "Passwort=%s\n", PlayerInfo[playerid][pPassword]);fwrite(hFile, var);
    format(var, 32, "Adminlevel=%d\n", PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
    PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
    format(var, 32, "Morde=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
    format(var, 32, "Tode=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
    format(var, 32, "Geld=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
    fclose(hFile);
    }
    }
    }
    return 1;
    }


    Die Stocks:
    stock ini_GetKey( line[] )
    {
    new keyRes[128];
    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[128];
    valRes[0]=0;
    if ( strfind( line , "=" , true ) == -1 ) return valRes;
    strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
    return valRes;
    }



    strtok(const string[], &index)
    {
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
    index++;
    }


    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
    result[index - offset] = string[index];
    index++;
    }
    result[index - offset] = EOS;
    return result;
    }



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


    So, das wars.