Problem bei Login System

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
  • Hallo ich habe eben folgendes Tutorial befolgt: [ SCRIPTING ] Simples Login- / Registersystem (mit DINI) , um ein Loginsystem zu scripten.
    Ich habe es selbst abgeschrieben, nur bekomme an einer Stelle ganz viele Errors. Ich habe auch schon probiert, den Teil zu kopieren und in mein Script einzufügen - ohne Erfolg.


    Hier ist mein Script:
    http://pastebin.com/yLhSaxTi



    Hier sind die Errors vom Compiler:


    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(148) : warning 217: loose indentation
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(156) : warning 217: loose indentation
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(158) : warning 219: local variable "save" shadows a variable at a preceding level
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(175) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(178) : warning 217: loose indentation
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(178) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(178) : error 004: function "OnPlayerEnterVehicle" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(180) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(183) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(183) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(183) : error 004: function "OnPlayerExitVehicle" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(185) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(188) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(188) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(188) : error 004: function "OnPlayerStateChange" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(190) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(193) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(193) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(193) : error 004: function "OnPlayerEnterCheckpoint" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(195) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(198) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(198) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(198) : error 004: function "OnPlayerLeaveCheckpoint" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(200) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(203) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(203) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(203) : error 004: function "OnPlayerEnterRaceCheckpoint" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(205) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(208) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(208) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(208) : error 004: function "OnPlayerLeaveRaceCheckpoint" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(210) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(213) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(213) : error 029: invalid expression, assumed zero
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(213) : error 004: function "OnRconCommand" is not implemented
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(215) : error 079: inconsistent return types (array & non-array)
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(218) : warning 225: unreachable code
    C:\Users\Lars\Desktop\SAMP_CODING\gamemodes\gamemode.pwn(218) : error 029: invalid expression, assumed zero


    Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    26 Errors.


    Außerdem wollte ich mal fragen, was "loose identation" bedeutet.


    Ich hoffe jemand findet den Fehler und kann mir helfen :).


    Liebe Grüße,


    lars96

  • Du hast bei den Befehlen unter OnPlayerCommandText 2 Klammern vergessen:


    // Gamemode v0.1
    // by LK


    #include <a_samp>
    #include <dini>


    enum info
    {
    passwort[128], // Passwort
    skin, // Skin
    };


    new pInfo[MAX_PLAYERS] [info];


    new bool:loggedin[MAX_PLAYERS];



    main()
    {
    print("\n----------------------------------");
    print("Gamemode by LK");
    print("----------------------------------\n");
    }


    stock strget(strx[], pos, search = ' ') {
    new arg, ret[128], idxx;
    for (new i = 0; i < strlen(strx); i++) {
    if(strx[i] == search || i == strlen(strx) || strx[i + 1] == 10) {
    arg++;
    if (arg == pos + 1){
    ret[i-idxx] = EOS;
    return ret;
    } else if (arg == pos)
    idxx= i+1;
    }
    else if (arg == pos)
    ret[i - idxx] = strx[i];
    }
    return ret;
    }


    public OnGameModeInit()
    {
    SetGameModeText("Fun Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
    }


    public OnGameModeExit()
    {
    return 1;
    }


    public OnPlayerRequestClass(playerid, classid)
    {
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
    }


    public OnPlayerConnect(playerid)
    {
    new name[128], save[128]; // Namen und Save Variable
    GetPlayerName(playerid, name, sizeof(name)); // Name des Spieler bekommen
    format(save, sizeof(save), "/player/%s.ini", name); // Dateinamen bekommen
    if (dini_Exists(save))
    {
    SendClientMessage(playerid, 0x33CCFFAA, "Benutze /login [passwort], um dich einzuloggen");
    GivePlayerMoney(playerid, dini_Int(save, "money")); // Spieler das gespeicherte Geld geben
    SetPlayerSkin(playerid, dini_Int(save, "skin")); // Spieler das gespeicherte Skin geben
    }
    else
    {
    if (!dini_Exists(save))
    {
    SendClientMessage(playerid, 0x33CCFFA, "Benutze /register [passwort], um dich zu registrieren");
    }
    }
    return 1;
    }


    public OnPlayerDisconnect(playerid, reason)
    {
    new name[128], save[128]; // Namen und Save Variable
    GetPlayerName(playerid, name, sizeof(name)); // Name des Spieler bekommen
    format(save, sizeof(save), "/player/%s.ini", name); // Dateinamen bekommen
    if (dini_Exists(save))
    {
    dini_IntSet(save, "money", GetPlayerMoney(playerid)); // speichert aktuelles Geld
    dini_IntSet(save, "skin", GetPlayerSkin(playerid)); // speichert aktuellen Skin
    }
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    new name[128], save[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(save, sizeof(save), "/player/%s.ini", name);
    if (loggedin[playerid] == false)
    {
    SendClientMessage(playerid, 0xAA3333AA, "Du musst dich einloggen, bevor du spawnst!");
    Kick(playerid);
    }
    SetPlayerSkin(playerid, dini_Int(save, "skin")); // gespeicherten Skin geben
    return 1;
    }


    public OnPlayerDeath(playerid, killerid, reason)
    {
    return 1;
    }


    public OnVehicleSpawn(vehicleid)
    {
    return 1;
    }


    public OnVehicleDeath(vehicleid, killerid)
    {
    return 1;
    }


    public OnPlayerText(playerid, text[])
    {
    return 1;
    }


    public OnPlayerCommandText(playerid, cmdtext[])
    {
    new player[MAX_PLAYER_NAME];


    // /register [password]
    if(strcmp(strget(cmdtext, 0), "/register", true) == 0)
    {
    new save[40]; // neuen String "save" erstellen
    GetPlayerName(playerid, player, sizeof(player));
    format(save, sizeof(save), "/player/%s.ini", player); // Speicherort
    if (!dini_Exists(save))
    {
    dini_Create(save); // ini Datei erzeugen
    dini_IntSet(save, "password", udb_hash(strget(cmdtext, 1))); // PW in ini verschlüsselt speichern
    SendClientMessage(playerid, 0x33AA33AA, "***Account wurde erstellt***");
    SendClientMessage(playerid, 0x33AA33AA, "***Du kannst dich nun mit /login (password) anmelden***");
    }
    else
    {
    if (dini_Exists(save))
    {
    SendClientMessage(playerid, 0xAA3333AA, "Der Account ist bereits registriert");
    }
    }
    }


    if(strcmp(strget(cmdtext,0), "/login", true) == 0)
    {
    new save[40], s2[256]; //gleiche wie oben
    GetPlayerName(playerid,player,sizeof(player));
    format(save,sizeof(save),"player/%s.ini",player);
    if(dini_Exists(save)) // wenn Datei existiert
    {
    s2=dini_Get(save,"passwort"); // lade das Passwort
    if(strval(s2)==udb_hash(strget(cmdtext,1))) // wenn die Eingabe nach /login mit dem Passwort von der registration übereinstimmt
    {
    loggedin[playerid] = true; //sage dem Server, dass der Spieler eingeloggt ist.
    SendClientMessage(playerid, 0x33CCFFAA, "***Du hast dich erfolgreich eingeloggt***");
    SpawnPlayer(playerid);
    }
    else // wenn das passwort nicht stimmt
    {
    SendClientMessage(playerid, 0xAA3333AA, "Passwort Falsch!");
    }
    }
    }
    return 1;
    }


    public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
    {
    return 1;
    }


    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    return 1;
    }


    public OnPlayerStateChange(playerid, newstate, oldstate)
    {
    return 1;
    }


    public OnPlayerEnterCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerEnterRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
    return 1;
    }


    public OnRconCommand(cmd[])
    {
    return 1;
    }


    public OnPlayerRequestSpawn(playerid)
    {
    return 1;
    }


    public OnObjectMoved(objectid)
    {
    return 1;
    }


    public OnPlayerObjectMoved(playerid, objectid)
    {
    return 1;
    }


    public OnPlayerPickUpPickup(playerid, pickupid)
    {
    return 1;
    }


    public OnVehicleMod(playerid, vehicleid, componentid)
    {
    return 1;
    }


    public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
    {
    return 1;
    }


    public OnVehicleRespray(playerid, vehicleid, color1, color2)
    {
    return 1;
    }


    public OnPlayerSelectedMenuRow(playerid, row)
    {
    return 1;
    }


    public OnPlayerExitedMenu(playerid)
    {
    return 1;
    }


    public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
    {
    return 1;
    }


    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {
    return 1;
    }


    public OnRconLoginAttempt(ip[], password[], success)
    {
    return 1;
    }


    public OnPlayerUpdate(playerid)
    {
    return 1;
    }


    public OnPlayerStreamIn(playerid, forplayerid)
    {
    return 1;
    }


    public OnPlayerStreamOut(playerid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamIn(vehicleid, forplayerid)
    {
    return 1;
    }


    public OnVehicleStreamOut(vehicleid, forplayerid)
    {
    return 1;
    }


    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    return 1;
    }


    public OnPlayerClickPlayer(playerid, clickedplayerid, source)
    {
    return 1;
    }


    stock strget(strx[], pos, search = ' ') {
    new arg, ret[128], idxx;
    for (new i = 0; i < strlen(strx); i++) {
    if(strx[i] == search || i == strlen(strx) || strx[i + 1] == 10) {
    arg++;
    if (arg == pos + 1){
    ret[i-idxx] = EOS;
    return ret;
    } else if (arg == pos)
    idxx= i+1;
    }
    else if (arg == pos)
    ret[i - idxx] = strx[i];
    }
    return ret;
    }

  • loose identation bedeutet das du die Zeile falsch eingerückt hast :)