MYSQL adminlevel wird nicht gespeichert

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
  • Hey, ich benutze das MYSQL Plugin R5 und irgendwie speichert er mein adminlevel nicht.
    Vielleicht könnt ihr mir helfen:


    setadmin code:
    ocmd:setadmin(playerid, params[])
    {
    new pID,a_level;
    new string[128];
    new string2[128];
    new adminx[MAX_PLAYER_NAME];
    new bef[MAX_PLAYER_NAME];
    GetPlayerName(playerid,adminx,sizeof(adminx));
    GetPlayerName(pID,bef,sizeof(bef));
    //if(!isAdmin(playerid,5))return SCM(playerid,HELLROT,"Du bist dazu nicht befugt!");
    if(sscanf(params,"ui",pID,a_level))return SCM(playerid,GRAU,"[Info] /setadmin [playerid] [level]");
    SpielerInfo[pID][pAlevel] = a_level;
    format(string,sizeof(string),"[SERVER]: %s wurde von Admin %s zum Admin Rang %i befördert.",bef,adminx,a_level);
    format(string2,sizeof(string2),"Du wurdest von %s zum Admin Rang %i befördert.",adminx,a_level);
    SendClientMessageToAll(HELLROT,string);
    SendClientMessage(pID,HELLBLAU,string2);
    SavePlayer(pID);
    return 1;
    }


    Alles was ich mit mysql habe:


    stock Connect_To_Database()
    {
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
    return 1;
    }
    stock mysql_CheckAccount(playerid)
    {
    new Query[128],Name[MAX_PLAYER_NAME],count;
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name, Name);
    format(Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(Query);
    mysql_store_result();
    count = mysql_num_rows();
    mysql_free_result();
    return count;
    }


    stock CreateAccount(playerid, pass[])
    {
    new query[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name,Name);
    mysql_real_escape_string(pass,pass);
    format(query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Passwort`) VALUES ('%s', '%s')", Name, pass);
    mysql_query(query);
    return true;
    }


    stock mysql_ReturnPasswort(Name[])
    {
    new query[130], Get[130];
    mysql_real_escape_string(Name, Name);
    format(query, 128, "SELECT `passwort` FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
    }


    stock LoadPlayer(playerid)
    {
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
    GetPlayerName(playerid, SpielerInfo[playerid][pName], MAX_PLAYER_NAME);
    SpielerInfo[playerid][pLevel] = mysql_GetInt("accounts", "Level", "Name", SpielerInfo[playerid][pName]);
    SpielerInfo[playerid][pGeld] = mysql_GetInt("accounts", "Geld", "Name", SpielerInfo[playerid][pName]);
    SpielerInfo[playerid][pKills] = mysql_GetInt("accounts", "Kills", "Name", SpielerInfo[playerid][pName]);
    SpielerInfo[playerid][pTode] = mysql_GetInt("accounts", "Tode", "Name", SpielerInfo[playerid][pName]);
    SpielerInfo[playerid][pAlevel] = mysql_GetInt("accounts","alevel","Name", SpielerInfo[playerid][pAlevel]);
    }
    return 1;
    }


    stock mysql_GetInt(Table[], Field[], Where[], Is[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    new sqlint = mysql_fetch_int();
    mysql_free_result();
    return sqlint;
    }


    stock mysql_GetString(Table[], Field[], Where[], Is[])
    {
    new query[128], Get[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
    }


    stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
    {
    new query[128], Float:sqlfloat;
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_float(sqlfloat);
    mysql_free_result();
    return sqlfloat;
    }


    stock SavePlayer(playerid)
    {
    if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
    {
    if(GetPVarInt(playerid,"Eingeloggt") == 1)
    {

    mysql_SetInt("accounts", "Level", SpielerInfo[playerid][pLevel], "Name", SpielerInfo[playerid][pName]);
    mysql_SetInt("accounts", "Geld", SpielerInfo[playerid][pGeld], "Name", SpielerInfo[playerid][pName]);
    mysql_SetInt("accounts", "Kills", SpielerInfo[playerid][pKills], "Name", SpielerInfo[playerid][pName]);
    mysql_SetInt("accounts", "Tode", SpielerInfo[playerid][pTode], "Name", SpielerInfo[playerid][pName]);
    mysql_SetFloat("accounts", "Health", SpielerInfo[playerid][pHealth], "Name", SpielerInfo[playerid][pName]);
    mysql_SetInt("accounts", "alevel", SpielerInfo[playerid][pAlevel], "Name", SpielerInfo[playerid][pAlevel]);
    }
    }
    return 1;
    }


    stock mysql_SetInt(Table[], Field[], To, Where[], Where2[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Where2, Where2);
    format(query, 128, "UPDATE `%s` SET `%s` = '%d' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
    mysql_query(query);
    return true;
    }
    stock mysql_SetString(Table[], Field[], To[], Where[], Where2[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(To, To);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Where2, Where2);
    format(query, 128, "UPDATE `%s` SET `%s` = '%s' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
    mysql_query(query);
    return true;
    }
    stock mysql_SetFloat(Table[], Field[], Float:To, Where[], Where2[])
    {
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Where2, Where2);
    format(query, 128, "UPDATE `%s` SET `%s` = '%f' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
    mysql_query(query);
    return true;
    }

    "Imagine if the government went after corruption as hard as it goes after guys who run filesharing sites. Priorities. " - @Snowden
    "More worrying than FBI temporarily running a server that contained child porn, is hacking computers anywhere in the world with one warrant" - @josephfcox

  • Dein Problem besteht hier


    mysql_SetInt("accounts", "alevel", SpielerInfo[playerid][pAlevel], "Name", SpielerInfo[playerid][pAlevel]);


    Bei dem letzten Parameter welcher für die Where-clausel ist musst du den namen übergeben.


    mysql_SetInt("accounts", "alevel", SpielerInfo[playerid][pAlevel], "Name", SpielerInfo[playerid][pName]);


    bei LoadPlayer ist der selbe Fehler wird dir das nicht als warning anzeigt oder hast du pAlevel als string angeben in deinem enum

  • Danke Prototype..:P Hab das nicht genau angeschaut.
    Hat funktioniert.

    "Imagine if the government went after corruption as hard as it goes after guys who run filesharing sites. Priorities. " - @Snowden
    "More worrying than FBI temporarily running a server that contained child porn, is hacking computers anywhere in the world with one warrant" - @josephfcox