Login/Register [Problem mit Format]

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
  • Ja, das Tutorial ist nicht das beste, da hast du Recht. Aber wenn du schon Kenntnisse hast sollte es für das meiste reichen. ;)


    So wie das aussieht hast du dini gar nicht inkludiert (#include <dini>).
    Mach das mal, sind die Errors dann weg, bzw. welche Errors bleiben?

  • Beitrag von JustMe.77 ()

    Dieser Beitrag wurde vom Autor gelöscht ().
  • Beitrag von JustMe.77 ()

    Dieser Beitrag wurde vom Autor gelöscht ().
  • Ja, da war ein Klammerfehler drin. Du hast eine } vergessen.
    Außerdem hast du das dcmd_register(...) in OnPlayerCommandText gepackt, das ist falsch. Du kannst das wie eine Funktion sehen, daher muss es außerhalb von Callbacks stehen, ich habe es dir mal ganz unten hingeschrieben.
    Nur die Einzeiler (dcmd(register, 8, cmdtext);) müssen bei OnPlayerCommandText hin.


    Code:

    Spoiler anzeigen
    //By JustMe.77
    #include <a_samp>
    #include <YSI\y_ini>
    #include <sscanf2>
    #include <Dini>
    #include <dudb>

    Spoiler anzeigen
    //Farben

    Spoiler anzeigen
    #define ROT 0xFF000FFF
    #define GELB 0xFFFF00FF

    Spoiler anzeigen
    #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

    Spoiler anzeigen
    new level[MAX_PLAYERS];
    new logged[MAX_PLAYERS];

    Spoiler anzeigen
    public OnPlayerConnect(playerid)
    {
    return 1;
    }

    Spoiler anzeigen
    public OnGameModeInit()
    {
    // Don't use these lines if it's a filterscript
    SetGameModeText("Hoe v0.1");
    AddPlayerClass(30,1914.8494,-2456.0183,13.5391,185.3171,24,200,25,100,34,100); //Spawnpunkt
    AddPlayerClass(48,1914.8494,-2456.0183,13.5391,185.3171,24,200,25,100,34,100);//Spawnpunkt
    AddPlayerClass(91,1914.8494,-2456.0183,13.5391,185.3171,24,200,25,100,34,100); //Spawnpunkt
    AddPlayerClass(93,1914.8494,-2456.0183,13.5391,185.3171,24,200,25,100,34,100);//Spawnpunkt

    UsePlayerPedAnims(); //Laufstil

    return 1;
    }

    Spoiler anzeigen
    public OnGameModeExit()
    {
    return 1;
    }

    Spoiler anzeigen
    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;
    }

    Spoiler anzeigen
    public OnPlayerDisconnect(playerid, reason)
    {
    return 1;
    }
    public OnPlayerSpawn(playerid)
    {
    // Give players full armour (100%) when they spawn.
    SetPlayerArmour(playerid, 100.0);
    return 1;
    }

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

    Spoiler anzeigen
    public OnVehicleSpawn(vehicleid)
    {
    return 1;
    }

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

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

    Spoiler anzeigen
    public OnPlayerCommandText(playerid, cmdtext[])
    {
    dcmd(register, 8, cmdtext);
    dcmd(login, 5, cmdtext);

    if(!strcmp("/heal", cmdtext, true))
    {
    SetPlayerHealth(playerid, 100);
    SetPlayerArmour(playerid, 100);
    return 1;
    }

    if(!strcmp("/kill", cmdtext, true))
    {
    SetPlayerHealth(playerid, 0);
    return 1;
    }

    if (strcmp(cmdtext, "/kungfu", true) == 0)
    {
    SetPlayerFightingStyle (playerid, FIGHT_STYLE_KUNGFU);
    SendClientMessage(playerid, 0xFFFFFFAA, "You have changed your fighting style to Kungfu!");
    return 1;
    }

    if(strcmp("/setday",cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid,GELB,"/setday [Wetter ID]");
    return 1;
    }

    if(strcmp("/setday 0",cmdtext, true, 10) == 0)
    {
    SetWeather(0);
    SendClientMessage(playerid,GELB,"Wetter umgeändert in EXTRASUNNY LA ");
    return 1;
    }

    if(strcmp("/setday 1",cmdtext, true, 10) == 0)
    {
    SetWeather(1);
    SendClientMessage(playerid,GELB,"Wetter umgeändert in SUNNY LA ");
    return 1;
    }

    if(strcmp("/setday 2",cmdtext, true, 10) == 0)
    {
    SetWeather(7);
    SendClientMessage(playerid,GELB,"Wetter umgeändert in CLOUDY SF");
    return 1;
    }

    if(strcmp("/settime",cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid,GELB,"/settime [TIME-ID]");
    return 1;
    }

    if(strcmp("/settime 0",cmdtext, true, 10) == 0)
    {
    SetPlayerTime(playerid, 0, 0); // Midnight
    SendClientMessage(playerid,GELB,"Zeit umgeändert auf Mitternacht");
    return 1;
    }

    if(strcmp("/settime 1",cmdtext, true, 10) == 0)
    {
    SetPlayerTime(playerid, 12, 0); // Midnight
    SendClientMessage(playerid,GELB,"Zeit umgeändert auf Mittag");
    return 1;
    }

    if(strcmp("/money",cmdtext, true, 10) == 0)
    {
    GivePlayerMoney(playerid, 50000);
    SendClientMessage(playerid,GELB,"Du hast 50.000 $ erhalten");
    return 1;
    }

    if (strcmp("/restart", cmdtext, true, 10) == 0)
    {
    SendClientMessage(playerid,ROT,"Server wird gestartet");
    SendRconCommand("gmx");
    return 1;
    }
    return 0;
    }

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

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

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

    Spoiler anzeigen
    public OnPlayerEnterCheckpoint(playerid)
    {
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerLeaveCheckpoint(playerid)
    {
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerEnterRaceCheckpoint(playerid)
    {
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerLeaveRaceCheckpoint(playerid)
    {
    return 1;
    }

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

    Spoiler anzeigen
    public OnPlayerRequestSpawn(playerid)
    {
    return 1;
    }

    Spoiler anzeigen
    public OnObjectMoved(objectid)
    {
    return 1;
    }

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

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

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

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

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

    Spoiler anzeigen
    public OnPlayerExitedMenu(playerid)
    {
    return 1;
    }

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

    Spoiler anzeigen
    public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
    {

    }

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

    Spoiler anzeigen
    public OnPlayerUpdate(playerid)
    {
    return 1;
    }

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

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

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

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

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

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

    Spoiler anzeigen
    public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
    {
    PlayerPlaySound(issuerid,17802,0.0,0.0,0.0); //Hitsound
    return 1;
    }

    Spoiler anzeigen
    dcmd_register(playerid, params[])
    {
    new file[128], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "\\Users\\%s.ini", pname);
    if(!strlen(params)) return SendClientMessage(playerid, ROT, "USAGE:/register [password]");
    if(dini_Exists(file)) return SendClientMessage(playerid, ROT, "You are already registered!");
    dini_Create(file);
    dini_IntSet(file, "hashPW", udb_hash(params));
    dini_Set(file, "password", params);
    dini_IntSet(file, "level", 0);
    dini_IntSet(file, "score", GetPlayerScore(playerid));
    dini_IntSet(file, "money", GetPlayerMoney(playerid));
    new string[128];
    format(string, 128, "You succesfully registered the nickname %s with password %s", pname, params);
    SendClientMessage(playerid, ROT, string);
    logged[playerid] = 1;
    SendClientMessage(playerid, ROT, "You have been automatically logged in!");
    return 1;
    }

    Spoiler anzeigen
    dcmd_login(playerid, params[])
    {
    new file[128];
    new string[128], pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "\\Users\\%s.ini", pname);
    if(!strlen(params)) return SendClientMessage(playerid, ROT, "USAGE: /login [password]");
    if(!dini_Exists(file)) return SendClientMessage(playerid, ROT, "You are not registered!");
    if(logged[playerid]) return SendClientMessage(playerid, ROT, "You are already logged in!");
    new tmp;
    tmp = dini_Int(file, "hashPW");
    if(udb_hash(params) != tmp)
    {
    format(string, 256, "You specified the wrong password for %s!", pname);
    SendClientMessage(playerid, ROT, string);
    }
    else
    {
    logged[playerid] = 1;
    level[playerid] = dini_Int(file, "level");
    SetPlayerScore(playerid, dini_Int(file, "score"));
    GivePlayerMoney(playerid, dini_Int(file, "money")-GetPlayerMoney(playerid));
    SendClientMessage(playerid, ROT, "You have succesfully logged in!");
    printf("%s (%i) logged in with password %s", pname, playerid, params);
    }
    return 1;
    }

  • Beitrag von JustMe.77 ()

    Dieser Beitrag wurde vom Autor gelöscht ().