[Erledigt] [MySQL-Problem] MySQL R39-3 // Accountspeicherung

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 liebe Breadfish-Nutzer. Ich habe heute nach langer Zeit mal wieder ein kleines MySQL-Accountspeicherungssystem geschrieben. Leider musste ich feststellen, dass leider mehrere Errors aufkreuzen. Könnte ihr mir vllt. helfen? Ich blicke da echt nicht dran lang an dem neuen MySQL. Bin schon etwas länger zum Thema scripten her inaktiv was MySQL angeht.


    //Dieses Script steht unter dem Copyrightschutz von Akaya.
    //Jede Verwendung ohne Erlaubnis wird strafrechtlich verfolgt.


    // ---------- Includes ----------


    #include <a_samp>
    #include <a_mysql>


    // ---------- Farben ------------


    #define ROT 0xFF0000FF
    #define BLAU 0x0000FFFF
    #define GRUEN 0x00FF00FF
    #define GELB 0xFFFF00FF
    #define ORANGE 0xFFC800FF
    #define GOLD 0x808000FF
    #define TUERKIS 0x00C8C8FF
    #define LILA 0xFF00FFFF


    // ---------- MySQL -------------


    #define SQL_HOST "localhost"
    #define SQL_USER "Testuser"
    #define SQL_PASS "Test123"
    #define SQL_DATA "Test"


    main()
    {
    print("German Reallife wurde erfolgreich geladen...");
    }


    public OnGameModeInit()
    {
    mysql_connect(SQL_HOST,SQL_USER,SQL_DATA,SQL_PASS);
    SetGameModeText("German Reallife");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
    }


    public OnGameModeExit()
    {
    mysql_close();
    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 query[126], pName[MAX_PLAYER_NAME];

    GetPlayerName(playerid, pName, sizeof(pName));

    format(query, sizeof(query), "SELECT * FROM account WHERE name = '%s'", pName);
    mysql_query(query);
    mysql_store_result();

    if(mysql_num_rows() == 1)
    {
    SendClientMessage(playerid, -1, "Der Spielername ist bereits vergeben!");
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Bitte logge dich nun mit deinem Passwort ein!", "Login", "Abbrechen");
    }
    else
    {
    return SendClientMessage(playerid, -1, "Der Spielername ist noch nicht vergeben. Du kannst dich nun registrieren!");
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registrieren", "Bitte wähle nun dein Passwort!", "Registrieren", "Abbrechen");
    }

    return 1;
    }


    public OnPlayerDisconnect(playerid, reason)
    {
    return 1;
    }


    public OnPlayerSpawn(playerid)
    {
    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[])
    {
    return 0;
    }


    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[])
    {
    switch(dialogid)
    {
    case 0;
    {
    if(response)
    {
    new query[126], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    format(query), sizeof(query), "SELECT * FROM account WHERE name = '%s' AND password = '%s'", pName, inputtext);
    mysql_query(query);
    mysql_store_result();

    if(mysql_num_rows() == 1)
    {
    SendClientMessage(playerid, -1, "Du hast dich erfolgreich angemeldet.");
    SetSpawnInfo(playerid, 1, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    }
    else
    }
    SendClientMessage(playerid, -1, "Falsches Passwort!");
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Bitte logge dich nun mit deinem Passwort ein!", "Login", "Abbrechen");
    }
    }
    }
    case 1;
    {
    if(response)
    {
    new query[126];, pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    format(query, sizeof(query), "INSERT INTO account VALUES ('%s', '%s'), pName, inputtext);
    mysql_query(query);

    SendClientMessage(playerid, -1, "Du hast dir erfolgreich einen Account angelegt!");

    SetSpawnInfo(playerid, 1, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    }
    }
    }
    return 1;
    }


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


    Errorcodes:
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(56) : warning 219: local variable "query" shadows a variable at a preceding level
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(61) : error 035: argument type mismatch (argument 1)
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(62) : error 017: undefined symbol "mysql_store_result"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(64) : error 017: undefined symbol "mysql_num_rows"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(72) : warning 225: unreachable code
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(242) : error 001: expected token: ":", but found ";"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(242) : error 036: empty statement
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(246) : warning 219: local variable "query" shadows a variable at a preceding level
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 202: number of arguments does not match definition
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 202: number of arguments does not match definition
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 215: expression has no effect
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 215: expression has no effect
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 215: expression has no effect
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 215: expression has no effect
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : error 001: expected token: ";", but found ")"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : error 029: invalid expression, assumed zero
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(249) : warning 215: expression has no effect
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(250) : error 035: argument type mismatch (argument 1)
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(251) : error 017: undefined symbol "mysql_store_result"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(253) : error 017: undefined symbol "mysql_num_rows"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(260) : error 029: invalid expression, assumed zero
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(261) : warning 217: loose indentation
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(265) : error 054: unmatched closing brace ("}")
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(266) : error 010: invalid function or declaration
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(268) : error 010: invalid function or declaration
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(270) : error 010: invalid function or declaration
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(273) : error 021: symbol already defined: "format"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(276) : error 021: symbol already defined: "SendClientMessage"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(278) : error 021: symbol already defined: "SetSpawnInfo"
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(283) : error 010: invalid function or declaration
    C:\Users\Admin\Desktop\Selfmade\gamemodes\Selfmade.pwn(290) : warning 203: symbol is never used: "query"
    Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    19 Errors.

    2 Mal editiert, zuletzt von Akaya ()

  • Spoiler anzeigen
    //Dieses Script steht unter dem Copyrightschutz von Akaya.
    //Jede Verwendung ohne Erlaubnis wird strafrechtlich verfolgt.

    Spoiler anzeigen
    // ---------- Includes ----------

    Spoiler anzeigen
    #include <a_samp>
    #include <a_mysql>

    Spoiler anzeigen
    // ---------- Farben ------------

    Spoiler anzeigen
    #define ROT 0xFF0000FF
    #define BLAU 0x0000FFFF
    #define GRUEN 0x00FF00FF
    #define GELB 0xFFFF00FF
    #define ORANGE 0xFFC800FF
    #define GOLD 0x808000FF
    #define TUERKIS 0x00C8C8FF
    #define LILA 0xFF00FFFF

    Spoiler anzeigen
    // ---------- MySQL -------------

    Spoiler anzeigen
    #define SQL_HOST "localhost"
    #define SQL_USER "Testuser"
    #define SQL_PASS "Test123"
    #define SQL_DATA "Test"

    Spoiler anzeigen
    main()
    {
    print("German Reallife wurde erfolgreich geladen...");
    }

    Spoiler anzeigen
    public OnGameModeInit()
    {
    mysql_connect(SQL_HOST,SQL_USER,SQL_DATA,SQL_PASS);
    SetGameModeText("German Reallife");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
    }

    Spoiler anzeigen
    public OnGameModeExit()
    {
    mysql_close();
    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 OnPlayerConnect(playerid)
    {
    new query[126], pName[MAX_PLAYER_NAME];

    Spoiler anzeigen
    GetPlayerName(playerid, pName, sizeof(pName));

    Spoiler anzeigen
    format(query, sizeof(query), "SELECT * FROM account WHERE name = '%s'", pName);
    mysql_query(query);
    mysql_store_result();

    Spoiler anzeigen
    if(mysql_num_rows() == 1)
    {
    SendClientMessage(playerid, -1, "Der Spielername ist bereits vergeben!");
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Bitte logge dich nun mit deinem Passwort ein!", "Login", "Abbrechen");
    }
    else
    {
    SendClientMessage(playerid, -1, "Der Spielername ist noch nicht vergeben. Du kannst dich nun registrieren!");
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Registrieren", "Bitte wähle nun dein Passwort!", "Registrieren", "Abbrechen");
    }
    return 1;
    }

    Spoiler anzeigen
    public OnPlayerDisconnect(playerid, reason)
    {
    return 1;
    }

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

    Spoiler anzeigen
    public OnPlayerDeath(playerid, killerid, 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[])
    {
    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 OnPlayerPickUpPickup(playerid, pickupid)
    {
    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)
    {
    return 1;
    }

    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[])
    {
    switch(dialogid)
    {
    case 0:
    {
    if(response)
    {
    new query[126], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    Spoiler anzeigen
    format(query, sizeof(query), "SELECT * FROM account WHERE name = '%s' AND password = '%s'", pName, inputtext);
    mysql_query(query);
    mysql_store_result();

    Spoiler anzeigen
    if(mysql_num_rows() == 1)
    {
    SendClientMessage(playerid, -1, "Du hast dich erfolgreich angemeldet.");
    SetSpawnInfo(playerid, 1, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    }
    else
    {
    SendClientMessage(playerid, -1, "Falsches Passwort!");
    ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Bitte logge dich nun mit deinem Passwort ein!", "Login", "Abbrechen");
    }
    }
    }
    case 1:
    {
    if(response)
    {
    new query[126], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    Spoiler anzeigen
    format(query, sizeof(query), "INSERT INTO account VALUES ('%s', '%s')", pName, inputtext);
    mysql_query(query);

    Spoiler anzeigen
    SendClientMessage(playerid, -1, "Du hast dir erfolgreich einen Account angelegt!");

    Spoiler anzeigen
    SetSpawnInfo(playerid, 1, 299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    }
    }
    }
    return 1;
    }

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


    Mit diesem Plugin und der beigefügten Include:
    http://forum.sa-mp.de/gta-mult…r-beispiel-50#post2084194

  • Da waren einige Syntax-Fehler im Code, vor allem in dem Callback ganz unten.
    Lege dir beide Versionen nebeneinander und vergleiche es, dann siehst du die Änderungen.


    Meistens nur ein falsches Zeichen, ein Zeichen zu viel oder ein fehlendes Zeichen, mehr war es nicht. Du solltest öfters kompilieren, dann passiert dir das nicht.