Jump to content
  • 0

[Help] afisare sanctiuni


Rayan

Question

Salut, am o comanda /last punish cu care verific fiecarui jucator sanctiunile.

Problema este ca nu afiseaza corect id-ul sanctiuni din baza de date, poza: https://imgur.com/a/ZpQyL

cod-ul este acesta:

if(strcmp(list,"punish",true) == 0)
            {
                new iddd;
                if(id != -1)
                {
                    format(query, sizeof(query), "SELECT * FROM `punishlogs` WHERE `playerid`='%d' ORDER BY `ID` DESC LIMIT %d", PlayerInfo[id][pSQLID], lines);
                    new Cache: resultt = mysql_query(SQL, query);
                    for(new i, j = cache_get_row_count (); i != j; ++i)
                    {
                        iddd                        = cache_get_field_content_int(i, "id");
                        cache_get_field_content(i, "time", result); format(test, 300, result);
                        cache_get_field_content(i, "reason", result); format(reason, 300, result);
                        actionid                    = cache_get_field_content_int(i, "actionid");
                        actiontime                  = cache_get_field_content_int(i, "actiontime");
                        cache_get_field_content(i, "playername", result); format(name, 30, result);
                        cache_get_field_content(i, "givername", result); format(name2, 30, result);
                        if(actionid == 1)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Ban: %s has been permanent banned by %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 2)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Ban: %s has been banned by %s for %d days, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 3)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] IP Ban: %s has been permanent banned by %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 4)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] IP Ban: %s has been banned by %s for %d days, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 5)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Warn: %s received a warn from admin %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 6)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Jail: %s was jailed by %s for %d minutes, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 7)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Mute: %s has been muted by %s for %d minutes, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 8)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] %s was released from jail by admin %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                    }
                    cache_delete(resultt);
                    ShowPlayerDialog(playerid,DIALOG_LASTS,DIALOG_STYLE_MSGBOX,"punish for player",string,"Close","");
                }
                else
                {
                    format(query, sizeof(query), "SELECT * FROM `punishlogs` ORDER BY `ID` DESC LIMIT %d", lines);
                    new Cache: resultt = mysql_query(SQL, query);
                    for(new i, j = cache_get_row_count (); i != j; ++i)
                    {
                        iddd                    = cache_get_field_content_int(i, "id");
                        cache_get_field_content(i, "time", result); format(test, 300, result);
                        cache_get_field_content(i, "reason", result); format(reason, 300, result);
                        actionid                    = cache_get_field_content_int(i, "actionid");
                        actiontime                  = cache_get_field_content_int(i, "actiontime");
                        cache_get_field_content(i, "playername", result); format(name, 30, result);
                        cache_get_field_content(i, "givername", result); format(name2, 30, result);
                        if(actionid == 1)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Ban: %s has been permanent banned by %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 2)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Ban: %s has been banned by %s for %d days, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 3)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] IP Ban: %s has been permanent banned by %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 4)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] IP Ban: %s has been banned by %s for %d days, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 5)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Warn: %s received a warn from admin %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 6)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Jail: %s was jailed by %s for %d minutes, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 7)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] Mute: %s has been muted by %s for %d minutes, reason: %s.\n",iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 8)
                        {
                            format(string,sizeof(string),"(#%d) %s[%s] %s was released from jail by admin %s, reason: %s.\n",iddd,string,test,name,name2,reason);
                        }
                    }
                    cache_delete(resultt);
                    ShowPlayerDialog(playerid,DIALOG_LASTS,DIALOG_STYLE_MSGBOX,"punish",string,"Close","");
                }
            }
Edited by Rayan
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
            if(strcmp(list,"punish",true) == 0)
            {
                new iddd;
                if(id != -1)
                {
                    string[0] = EOS;
                    format(query, sizeof(query), "SELECT * FROM `punishlogs` WHERE `playerid`= %d ORDER BY `ID` DESC LIMIT %d", PlayerInfo[id][pSQLID], lines);
                    new Cache: resultt = mysql_query(SQL, query);
                    for(new i, j = cache_get_row_count (); i != j; ++i)
                    {
                        iddd                        = cache_get_field_content_int(i, "id");
                        cache_get_field_content(i, "time", test);
                        cache_get_field_content(i, "reason", reason);
                        actionid                    = cache_get_field_content_int(i, "actionid");
                        actiontime                  = cache_get_field_content_int(i, "actiontime");
                        cache_get_field_content(i, "playername", name);
                        cache_get_field_content(i, "givername", name2);
                        if(actionid == 1)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Ban: %s has been permanent banned by %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 2)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Ban: %s has been banned by %s for %d days, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 3)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] IP Ban: %s has been permanent banned by %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 4)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] IP Ban: %s has been banned by %s for %d days, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 5)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Warn: %s received a warn from admin %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 6)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Jail: %s was jailed by %s for %d minutes, reason: %s.\n",stringiddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 7)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Mute: %s has been muted by %s for %d minutes, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 8)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] %s was released from jail by admin %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                    }
                    cache_delete(resultt);
                    ShowPlayerDialog(playerid,DIALOG_LASTS,DIALOG_STYLE_MSGBOX,"punish for player",string,"Close","");
                }
                else
                {
                    string[0] = EOS;
                    format(query, sizeof(query), "SELECT * FROM `punishlogs` ORDER BY `ID` DESC LIMIT %d", lines);
                    new Cache: resultt = mysql_query(SQL, query);
                    for(new i, j = cache_get_row_count (); i != j; ++i)
                    {
                        iddd                    = cache_get_field_content_int(i, "id");
                        cache_get_field_content(i, "time", test); 
                        cache_get_field_content(i, "reason", reason);
                        actionid                    = cache_get_field_content_int(i, "actionid");
                        actiontime                  = cache_get_field_content_int(i, "actiontime");
                        cache_get_field_content(i, "playername", name);
                        cache_get_field_content(i, "givername", name2);
                        if(actionid == 1)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Ban: %s has been permanent banned by %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 2)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Ban: %s has been banned by %s for %d days, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 3)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] IP Ban: %s has been permanent banned by %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 4)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] IP Ban: %s has been banned by %s for %d days, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 5)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Warn: %s received a warn from admin %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                        else if(actionid == 6)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Jail: %s was jailed by %s for %d minutes, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 7)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] Mute: %s has been muted by %s for %d minutes, reason: %s.\n",string,iddd,string,test,name,name2,actiontime,reason);
                        }
                        else if(actionid == 8)
                        {
                            format(string,sizeof(string),"%s(#%d) %s[%s] %s was released from jail by admin %s, reason: %s.\n",string,iddd,string,test,name,name2,reason);
                        }
                    }
                    cache_delete(resultt);
                    ShowPlayerDialog(playerid,DIALOG_LASTS,DIALOG_STYLE_MSGBOX,"punish",string,"Close","");
                }
            }

Ce ai uitat tu sa faci este sa oferi la stringuri o continuitate , fiind intr-o bucla care e de n ori formatezi acelasi string de n ori si nu il copiezi pe cel precedent la cel actual. Sunt 2 variainte, cum a facut eu sau folosind strcat(putin mai optim). Practic copiai o informatie de n ori fara sa salvezi ce era inaintea ei si ramanea ultima(sper sa fie de la asta , altceva nu vad)

Link to comment
Share on other sites

  • 0
1 oră în urmă, Banditul a spus:

Ce ai uitat tu sa faci este sa oferi la stringuri o continuitate , fiind intr-o bucla care e de n ori formatezi acelasi string de n ori si nu il copiezi pe cel precedent la cel actual. Sunt 2 variainte, cum a facut eu sau folosind strcat(putin mai optim). Practic copiai o informatie de n ori fara sa salvezi ce era inaintea ei si ramanea ultima(sper sa fie de la asta , altceva nu vad)

Acum arata asa: https://imgur.com/a/l5rXN

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.