Jump to content
  • 0
Sign in to follow this  
Dnk1221

Problema comanda

Question

Salut, am inceput sa invat sa scriptez mai amanuntit si ajungand aici m-am blocat putin.

Problema mea este ca am creeat o comanda cu care transmit un text tuturor si acel text se salveaza in baza de date cu diferite date, cum ar fii data, id-ul, ip, si text-ul.

Dupa aceea am incercat sa creez o comanda care sa imi afiseze ce sa salvat in baza de date dar chiar nu gasesc undeva ceva sa imi fac o idee cum sa o fac.

Am incercat sa ma uit intr-un gm la comanda emails sa o fac ceva gen dar nu am reusit.

Cine imi poate da o ideei mica sau un link unde pot gasi ceva de genu sa imi dau seama cum ar trebui facuta.

 

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
CMD:comanda(playerid, params[])
{
    inline InlineCallback()
	{
		new date[40], id, ip[16], text[144], dialogMessage[144], rows = cache_num_rows();
        if(rows)
        {
            for(new row = 0; row < rows; row++)
            {
                cache_get_value_name_int(row, "id", id);
                cache_get_value_name(row, "date", date);
                cache_get_value_name(row, "ip", ip);
                cache_get_value_name(row, "text", text);

                format(dialogMessage, sizeof(dialogMessage), "%s%i(%s). %s (%s)\n", dialogMessage, id, ip, text, date);
            }

            ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Log ", dialogMessage, button1[], button2[]);
        }
	}

    new ret = mysql_tquery_inline(g_Mysql, "SELECT * FROM Logs", using inline InlineCallback);
		
	if(!ret)
		printf("some error happened, check the MySQL log!");
}

Asta ar fi idea mea generala, evident acum editezi tu cum vrei, doar am incercat sa dau un exemplu mediocru (a fost destul de dificil de scris dupa ce nu mai ai atins pawn de luni)

PS: https://github.com/maddinat0r/samp-mysql-yinline-include (nu e nevoie sa foloseti asta desigur ce am  dat mai sus dar mie unu imi place codul care poate fi executat inline)

CMD:comanda(playerid, params[])
{
    new Cache:cache = mysql_query(g_Mysql, "SELECT * FROM Logs");
    new date[40], id, ip[16], text[144], dialogMessage[144], rows = cache_num_rows();
    if(rows)
    {
        for(new row = 0; row < rows; row++)
        {
            cache_get_value_name_int(row, "id", id);
            cache_get_value_name(row, "date", date);
            cache_get_value_name(row, "ip", ip);
            cache_get_value_name(row, "text", text);

            format(dialogMessage, sizeof(dialogMessage), "%s%i(%s). %s (%s)\n", dialogMessage, id, ip, text, date);
        }

        ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Log ", dialogMessage, button1[], button2[]);
    }	
	cache_delete(cache);
}

Aici ^^ implementarea clasica

PS1: Asta e MySQL r40+, daca folosesti alta versiune va trebui sa modifici ce e nevoie

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0
16 hours ago, Banditul said:

CMD:comanda(playerid, params[])
{
    inline InlineCallback()
	{
		new date[40], id, ip[16], text[144], dialogMessage[144], rows = cache_num_rows();
        if(rows)
        {
            for(new row = 0; row < rows; row++)
            {
                cache_get_value_name_int(row, "id", id);
                cache_get_value_name(row, "date", date);
                cache_get_value_name(row, "ip", ip);
                cache_get_value_name(row, "text", text);

                format(dialogMessage, sizeof(dialogMessage), "%s%i(%s). %s (%s)\n", dialogMessage, id, ip, text, date);
            }

            ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Log ", dialogMessage, button1[], button2[]);
        }
	}

    new ret = mysql_tquery_inline(g_Mysql, "SELECT * FROM Logs", using inline InlineCallback);
		
	if(!ret)
		printf("some error happened, check the MySQL log!");
}

Asta ar fi idea mea generala, evident acum editezi tu cum vrei, doar am incercat sa dau un exemplu mediocru (a fost destul de dificil de scris dupa ce nu mai ai atins pawn de luni)

PS: https://github.com/maddinat0r/samp-mysql-yinline-include (nu e nevoie sa foloseti asta desigur ce am  dat mai sus dar mie unu imi place codul care poate fi executat inline)


CMD:comanda(playerid, params[])
{
    new Cache:cache = mysql_query(g_Mysql, "SELECT * FROM Logs");
    new date[40], id, ip[16], text[144], dialogMessage[144], rows = cache_num_rows();
    if(rows)
    {
        for(new row = 0; row < rows; row++)
        {
            cache_get_value_name_int(row, "id", id);
            cache_get_value_name(row, "date", date);
            cache_get_value_name(row, "ip", ip);
            cache_get_value_name(row, "text", text);

            format(dialogMessage, sizeof(dialogMessage), "%s%i(%s). %s (%s)\n", dialogMessage, id, ip, text, date);
        }

        ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, "Log ", dialogMessage, button1[], button2[]);
    }	
	cache_delete(cache);
}

Aici ^^ implementarea clasica

PS1: Asta e MySQL r40+, daca folosesti alta versiune va trebui sa modifici ce e nevoie

Mersi am inteles cum trebuie facuta o comanda de genu, o seara frumoasa sa ai. +1.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

This site uses cookies. By continuing browsing, you agree to the use of this information. For more details, see Terms of Use and Privacy Policy.