Stats werden bei falschem Passwort zurückgesetzt

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
  • Wenn ich connecte und drei mal mein Passwort falsch eingebe, wird in der mySQL DB meine Stats(Level,Adminlevel,Geld,Wanteds) zurückgesetzt... was kann ich da tun?
    public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
    {
    new pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(dialogid)
    {
    case DIALOG_LOGIN1:
    {
    if(response)
    {
    new query[256],passwort[40];
    if(strlen(inputtext)>0)
    {
    mysql_escape_string(inputtext,passwort,dbhandle);
    format(query,sizeof(query),"SELECT username,password,sex,age,adminlevel,level,money,faction,rank,wanteds FROM user WHERE username='%s' AND password='%s'",pname,passwort);
    mysql_function_query(dbhandle,query,true,"PasswortAbfrage","i",playerid);
    }
    else
    {
    SendClientMessage(playerid,Gelb,"Gib ein Passwort ein!");
    ShowPlayerDialog(playerid,DIALOG_LOGIN1,DIALOG_STYLE_PASSWORD,"Login","Dein Passwort:","OK","Abbrechen");
    }
    }
    else
    {
    Kick(playerid);
    }
    }
    public PasswortAbfrage(playerid)
    {
    new num_fields,num_rows;
    cache_get_data(num_rows,num_fields,dbhandle);
    if(num_rows>0)
    {
    pInfo[playerid][Logged] = 1;
    pInfo[playerid][Level] = cache_get_field_content_int(0,"level",dbhandle);
    pInfo[playerid][Geschlecht] = cache_get_field_content_int(0,"sex",dbhandle);
    pInfo[playerid][Alter] = cache_get_field_content_int(0,"age",dbhandle);
    pInfo[playerid][Adminlevel] = cache_get_field_content_int(0,"adminlevel",dbhandle);
    pInfo[playerid][Geld] = cache_get_field_content_int(0,"money",dbhandle);
    pInfo[playerid][Fraktion] = cache_get_field_content_int(0,"faction",dbhandle);
    pInfo[playerid][Rang] = cache_get_field_content_int(0,"rank",dbhandle);
    pInfo[playerid][Wanteds] = cache_get_field_content_int(0,"wanteds",dbhandle);
    //Sterne
    if(pInfo[playerid][Wanteds] >=10 && pInfo[playerid][Wanteds]<20) SetPlayerWantedLevel(playerid,1);
    if(pInfo[playerid][Wanteds] >=20 && pInfo[playerid][Wanteds]<30) SetPlayerWantedLevel(playerid,2);
    if(pInfo[playerid][Wanteds] >=30 && pInfo[playerid][Wanteds]<40) SetPlayerWantedLevel(playerid,3);
    if(pInfo[playerid][Wanteds] >=40 && pInfo[playerid][Wanteds]<50) SetPlayerWantedLevel(playerid,4);
    if(pInfo[playerid][Wanteds] >=50 && pInfo[playerid][Wanteds]<69) SetPlayerWantedLevel(playerid,5);
    if(pInfo[playerid][Wanteds] ==69) SetPlayerWantedLevel(playerid,6);
    TextDrawShowForPlayer(playerid, Time), TextDrawShowForPlayer(playerid, Date);
    SetPlayerScore(playerid,pInfo[playerid][Level]);
    new altmoney = GetPlayerMoney(playerid);
    GivePlayerMoney(playerid,-altmoney);
    GivePlayerMoney(playerid,pInfo[playerid][Geld]);
    SetSpawnInfo(playerid,0,29,-1969.4128,137.6455,27.6875,91.5533,0,0,0,0,0,0);
    SpawnPlayer(playerid);
    }
    else
    {
    SetPVarInt(playerid,"badlogin",GetPVarInt(playerid,"badlogin")+1);
    if(GetPVarInt(playerid,"badlogin")<3)
    {
    SendClientMessage(playerid,Rot,"Dieses Passwort war falsch!");
    ShowPlayerDialog(playerid,DIALOG_LOGIN1,DIALOG_STYLE_PASSWORD,"Login","Dein Passwort:","OK","Abbrechen");
    }
    if(GetPVarInt(playerid,"badlogin") >=3)
    {
    SendClientMessage(playerid,Rot,"Du wurdest gekickt, weil du dein Passwort dreimal falsch eingegeben hast!");
    Kick(playerid);
    }
    }
    return 1;
    }
    Andere Frage: Wird bei einem Kick OnPlayerDisconnect aufgerufen? Falls ja, dort werden die Stats gespeichert, aber somit auch bei einem Kick (das soll nicht so sein).. Wie könnte ich das beheben?

    Greetz

  • Gespeichert wird beim Disconnect
    public OnPlayerDisconnect(playerid, reason)
    {
    TextDrawHideForPlayer(playerid, Time), TextDrawHideForPlayer(playerid, Date);
    new query[128],pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    format(query,sizeof(query),"UPDATE user SET banned ='%d',adminlevel='%d',level='%d',money='%d',faction='%d',rank='%d',wanteds='%d' WHERE username='%s'",pInfo[playerid][Banned],pInfo[playerid][Adminlevel],pInfo[playerid][Level],pInfo[playerid][Geld],pInfo[playerid][Fraktion],pInfo[playerid][Rang],pInfo[playerid][Wanteds],pname);
    mysql_function_query(dbhandle,query,false,"","");
    pInfo[playerid][Logged] = 0;
    DeleteTicket(playerid);
    return 1;
    }

    Greetz