Doppeltes Geld?

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
  • Guten Tag,


    ich arbeite an meinem Geldsystem, jedoch wenn ich mir per MySQL '2500€' gebe, habe ich Ingame '5000€', an was kann es liegen?


    Hier Code:

    stock GivePlayerEuro(playerid,euros)
    {
    AccountInfo[playerid][sGeld] += euros;
    new geld[64];
    format(geldtext,64,"%d",AccountInfo[playerid][sGeld]);
    TextDrawSetString(GeldZahl[playerid],geld);
    }


    stock GetPlayerEuro(playerid)
    {
    return AccountInfo[playerid][sGeld];
    }


    Laden:
    AccountInfo[playerid][sGeld] = mysql_GetInt("accounts","Geld","Name",AccountInfo[playerid][sName]);
    GivePlayerEuro(playerid,AccountInfo[playerid][sGeld]);


    Speichern:
    mysql_SetInt("accounts","Geld",GetPlayerEuro(playerid),"Name",AccountInfo[playerid][sName]);
    mysql_SetInt("accounts","Geld",AccountInfo[playerid][sGeld],"Name",AccountInfo[playerid][sName]);


    Ich bedanke mich im vorraus!

  • Das ist simple Mathematik


    AccountInfo[playerid][sGeld] = mysql_GetInt("accounts","Geld","Name",AccountInfo[playerid][sName]);


    AccountInfo[playerid][sGeld] hat nun 2500


    nun deine FUnktion


    GivePlayerEuro(playerid,AccountInfo[playerid][sGeld]);


    AccountInfo[playerid][sGeld] += euros;


    so wird nochmal der selbe betrag dazu addiert und wir sind bei 5000


    daher mach es so
    GivePlayerEuro(playerid,mysql_GetInt("accounts","Geld","Name",AccountInfo[playerid][sName]));
    mysql_GetInt gibt den betrag welcher in der Zelle steht zurück