Jump to content
  • 0

Problema chatlog


AlexStorm

Question

Problema intalnita (descriere): Salut. M-am gandit sa fac o comanda care afiseaza intr-un tabel ce a scris un player in chat. Totul merge ok, doar ca se afiseaza toate mesajele care le-a scris. Eu vreau sa apara doar ultimile 10 mesaje. Am incercat sa fac o limita la string sa afiseze doar 10, dar nu le afiseaza pe cele mai recente, ci pe primele care le-a scris.
Ero(area / rile) / warning-(ul / urile): Nu am warning-uri. Totul merge bine, doar ca nu stiu cum as putea face.
Liniile de cod / sursa / script-ul(obligatoriu):

if(strcmp(action,"chat",true) == 0)
			{
				new stringg[256];
				new aim[2000];

				mysql_format(handle, stringg, sizeof(stringg), "SELECT * FROM `chatlogs` WHERE ID = %d", playerVariables[id][pID]);
				new test[256], test2[256];
				new Cache: result12 = mysql_query (handle, stringg);
				for(new i, j = cache_get_row_count(); i != j; ++i)
				{
					cache_get_field_content(i, "text", test);
					cache_get_field_content(i, "time", test2);
		            
		            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
			    	ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

				}
				cache_delete(result12);
			}


Imagini / Video (optional): === 
Ati incercat sa rezolvati singur?:  Totul am facut singur, dar de aici nu mai stiu si cer ajutor.

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0
for(new i = cache_get_row_count(), i < cache_get_row_count()-10; i--)
				{
					cache_get_field_content(i, "text", test);
					cache_get_field_content(i, "time", test2);
		            
		            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
			    	ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

Incearca asa

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

  • 0
3 hours ago, Gireada said:

for(new i = cache_get_row_count(), i < cache_get_row_count()-10; i--)
				{
					cache_get_field_content(i, "text", test);
					cache_get_field_content(i, "time", test2);
		            
		            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
			    	ShowPlayerDialog(playerid, 2000, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

Incearca asa

Primesc errori:

 error 021: symbol already defined: "i"
 error 001: expected token: ")", but found ";"
 warning 204: symbol is assigned a value that is never used: "i"

Link to comment
Share on other sites

  • 0
20 minutes ago, Gireada said:

for(i = cache_get_row_count(); i < cache_get_row_count()-10; i--)

Mai grav decat mainainte :))

error 017: undefined symbol "i"
error 017: undefined symbol "i"
warning 215: expression has no effect
error 001: expected token: ")", but found ";"
fatal error 107: too many error messages on one line

 

#edit: Am pus asa

new i = cache_get_row_count();

for(i = cache_get_row_count(); i < cache_get_row_count()-10; i--)

 

Nu mai am errorile doar ca daca dau /last chat in joc acum nu mai afiseaza deloc tabelul cu mesajele.. 
 

Edited by AlexStorm
Link to comment
Share on other sites

  • 0
9 minutes ago, Gireada said:

for(i = cache_get_row_count(); i > cache_get_row_count()-10; i--)

            if(strcmp(action,"chat",true) == 0)
            {
                new stringg[256];
                new aim[2000];

                mysql_format(handle, stringg, sizeof(stringg), "SELECT * FROM `chatlogs` WHERE ID = %d", playerVariables[id][pID]);
                new test[256], test2[256];
                new Cache: result12 = mysql_query (handle, stringg);
                new i = cache_get_row_count();
                for(i = cache_get_row_count(); i > cache_get_row_count()-10; i--)
                {
                    cache_get_field_content(i, "text", test);
                    cache_get_field_content(i, "time", test2);

                    format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
                    ShowPlayerDialog(playerid, 256, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

                }
                cache_delete(result12);
            }

 

Asa arata. Acum imi afiseaza mesajele.. Problema este ca am doar un mesaj salvat in baza de date doar de test.. si se afiseaza de 10 ori acelasi mesaj in loc sa afiseze doar unul..

Poza: http://imgur.com/JXERf9Q

iar null ala nu stiu de la ce e :-?

 

#edit: Am incercat sa scriu mai multe mesaje in chat, apare corect.. doar ca null ala deranjeaza.. stii cum as putea sa fac sa nu mai scrie null + sa apara daca are doar un mesaj scris in chat de cand se inregistreaza doar pe ala sa il afiseze si nu de 10 ori? Iti multumesc frumos ca ma ajuti.

Edited by AlexStorm
Link to comment
Share on other sites

  • 0

if(strcmp(action,"chat",true) == 0)
{
    new stringg[256];
    new aim[2000];

    mysql_format(handle, stringg, sizeof(stringg), "SELECT * FROM `chatlogs` WHERE ID = %d", playerVariables[id][pID]);
    new test[256], test2[256];
    new Cache: result12 = mysql_query (handle, stringg);
    new i = cache_get_row_count();
    if(i > 10)
    {
        for(i = cache_get_row_count(); i > cache_get_row_count()-10; i--)
        {
            cache_get_field_content(i, "text", test);
            cache_get_field_content(i, "time", test2);

            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
            ShowPlayerDialog(playerid, 256, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

        }
    }
    else
    {
        for(i = cache_get_row_count(); i > 1; i--)
        {
            cache_get_field_content(i, "text", test);
            cache_get_field_content(i, "time", test2);

            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
            ShowPlayerDialog(playerid, 256, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

        }
    }
    cache_delete(result12);
}

 

Asa arata.

Edited by Gireada

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Link to comment
Share on other sites

  • 0
1 hour ago, Gireada said:

if(strcmp(action,"chat",true) == 0)
{
    new stringg[256];
    new aim[2000];

    mysql_format(handle, stringg, sizeof(stringg), "SELECT * FROM `chatlogs` WHERE ID = %d", playerVariables[id][pID]);
    new test[256], test2[256];
    new Cache: result12 = mysql_query (handle, stringg);
    new i = cache_get_row_count();
    if(i > 10)
    {
        for(i = cache_get_row_count(); i > cache_get_row_count()-10; i--)
        {
            cache_get_field_content(i, "text", test);
            cache_get_field_content(i, "time", test2);

            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
            ShowPlayerDialog(playerid, 256, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

        }
    }
    else
    {
        for(i = cache_get_row_count(); i > 1; i--)
        {
            cache_get_field_content(i, "text", test);
            cache_get_field_content(i, "time", test2);

            format(aim,sizeof(aim),"%s[%s] %s\n",aim, test2, test);
            ShowPlayerDialog(playerid, 256, DIALOG_STYLE_MSGBOX, "chat for player", aim, "Close", "");

        }
    }
    cache_delete(result12);
}

 

Asa arata.

@Gireada esti un mare om. Iti multumesc. Doar ca mai am o rugaminte.. daca poti si vrei sa ma ajuti..

Apare acolo NULL.. ai idee de ce? 

Dovezi: http://imgur.com/a/k56lF

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.