PlayerInfo[playerid][pSQLID] = INI_ReadInt("SQLID");

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
  • ImportOldPlayerFile(playerid)
    {
    new rstring[MAX_PLAYER_NAME+18];
    format(rstring, sizeof(rstring), "spielerdaten/%s.ini", GetName(playerid));
    INI_Open(rstring);
    INI_ReadString(PlayerInfo[playerid][pKey], "Passwort", MAX_PASSWORT_LENGTH);
    WP_Hash(PlayerInfo[playerid][pKey],512,PlayerInfo[playerid][pKey]);
    PlayerInfo[playerid][pLevel] = INI_ReadInt("Level");
    PlayerInfo[playerid][pFraktion] = INI_ReadInt("Fraktion");
    PlayerInfo[playerid][pDonateRank] = INI_ReadInt("DonateRank");
    PlayerInfo[playerid][gPupgrade] = INI_ReadInt("UpgradePoints");
    PlayerInfo[playerid][pConnectTime] = INI_ReadInt("ConnectedTime");
    PlayerInfo[playerid][pReg] = INI_ReadInt("Registered");

  • GetSpielerPasswort(playerid)
    {
    format(CacheString, sizeof(CacheString), "SELECT Passwort FROM gf_players WHERE SpielerName = '%s';",GetName(playerid));
    mysql_query(CacheString);
    mysql_store_result();
    mysql_retrieve_row();
    mysql_fetch_field_row(PlayerInfo[playerid][pKey],"Passwort");
    mysql_free_result();
    }
    SavePlayerSQLInt(playerid,field[],setint)
    {
    format(CacheString,sizeof(CacheString),"UPDATE gf_players SET %s = '%i' WHERE SpielerName = '%s';",field,setint,GetName(playerid));
    mysql_query(CacheString);
    return true;
    }
    SavePlayerSQLFloat(playerid,field[],Float:setfloat)
    {
    format(CacheString,sizeof(CacheString),"UPDATE gf_players SET %s = '%f' WHERE SpielerName = '%s';",field,setfloat,GetName(playerid));
    mysql_query(CacheString);
    return true;
    }
    SavePlayerSQLString(playerid,field[],setstring[])
    {
    format(CacheString,sizeof(CacheString),"UPDATE gf_players SET %s = '%s' WHERE SpielerName = '%s';",field,setstring,GetName(playerid));
    mysql_query(CacheString);
    return true;
    }
    ReadPlayerSQLInt(playerid,field[])
    {
    format(CacheString,sizeof(CacheString),"SELECT %s FROM gf_players WHERE SpielerName = '%s';",field,GetName(playerid));
    mysql_query(CacheString);
    mysql_store_result();
    new mysqlint=mysql_fetch_int();
    mysql_free_result();
    return mysqlint;
    }
    Float:ReadPlayerSQLFloat(playerid,field[])
    {
    format(CacheString,sizeof(CacheString),"SELECT %s FROM gf_players WHERE SpielerName = '%s';",field,GetName(playerid));
    mysql_query(CacheString);
    mysql_store_result();
    new Float:mysqlfloat;
    mysql_fetch_float(mysqlfloat);
    mysql_free_result();
    return mysqlfloat;
    }
    ReadPlayerSQLString(playerid,field[],buffer[])
    {
    format(CacheString,sizeof(CacheString),"SELECT %s FROM gf_players WHERE SpielerName = '%s';",field,GetName(playerid));
    mysql_query(CacheString);
    mysql_store_result();
    mysql_retrieve_row();
    mysql_fetch_field_row(buffer,field);
    mysql_free_result();
    return true;
    }




    LadeInventar(playerid)
    {
    new cnr[8];
    format(CacheString, 256, "spielerdaten/%s.inv", GetName(playerid));
    if(INI_Open(CacheString))
    {
    for(new id = 0; id < MAX_PRODUCTS; id++)
    {
    Inventar[playerid][id][ivpSlot] = -1; Inventar[playerid][id][ivpMenge] = -1; Inventar[playerid][id][ivpAblauf] = -1;
    Itter_Remove(PInventar[playerid], id);
    valstr(cnr, id);
    INI_ReadString(CacheString, cnr);
    sscanf(CacheString, "p<;>iiiis[128]f",
    Inventar[playerid][id][ivpSlot],
    Inventar[playerid][id][ivpMenge],
    Inventar[playerid][id][ivpAblauf],
    Inventar[playerid][id][ivpNumber],
    Inventar[playerid][id][ivpString],
    Inventar[playerid][id][ivpFloat]);
    if(Inventar[playerid][id][ivpSlot] != -1) Itter_Add(PInventar[playerid], id);
    }
    INI_Close();
    }
    return true;
    }


    SpeichereInventar(playerid)
    {
    new cnr[8];
    format(CacheString, 256, "spielerdaten/%s.inv", GetName(playerid));
    if(INI_Open(CacheString))
    {
    foreach(PInventar[playerid], id)
    {
    valstr(cnr, id);
    format(CacheString, 256, "%i;%i;%i;%i;%s;%f",
    Inventar[playerid][id][ivpSlot],
    Inventar[playerid][id][ivpMenge],
    Inventar[playerid][id][ivpAblauf],
    Inventar[playerid][id][ivpNumber],
    Inventar[playerid][id][ivpString],
    Inventar[playerid][id][ivpFloat]);
    INI_WriteString(cnr, CacheString);
    }
    INI_Save();
    //INI_Close();
    }
    return true;
    } //edit noch was zugefügt

    Einmal editiert, zuletzt von Büttii<3 ()

  • Achso du möchtest es von MySql in INI umschreiben sag das doch gleich =).
    Beim speichern INI_WriteInt / WriteString / WriteFloat benutzen.
    Beim laden INI_ReadInt / ReadString / ReadFloat benutzen.



    sprich:



    GetSpielerPasswort(playerid)
    {
    format(CacheString, sizeof(CacheString), "SELECT Passwort FROM gf_players WHERE SpielerName = '%s';",GetName(playerid));
    mysql_query(CacheString);
    mysql_store_result();
    mysql_retrieve_row();
    mysql_fetch_field_row(PlayerInfo[playerid][pKey],"Passwort");
    mysql_free_result();
    }



    zu



    GetSpielerPasswort(playerid)
    {
    new STR[32];
    format(STR, 32, "%s.ini", GetName(playerid));
    if(INI_Open(STR))
    {
    PlayerInfo[playerid][pKey] = INI_ReadInt("Passwort");
    }
    }


    usw. Aber zum laden kannst du es gleich in die Login Funktion tuhen wozu für jede Spalte ne neue Funktion benutze ?



    //edit:


    Und beim speichern ist es ganz wichtig nach dem Speichern "INI_Save();" zu benutzen da die File sonst nicht gespeichert wird.


    MFG RFT

    RFT