SA-MP Forums Archive
Mysql Problem! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql Problem! (/showthread.php?tid=592953)



Mysql Problem! - Ugaustin - 31.10.2015

im keep getting spammed..

PHP код:
if(strcmp(cmd"/123"true) == 0)
                    {
                         
CheckQuery1(playerid);
                        return 
1;
                    } 
PHP код:
public CheckQuery1(playerid)
{
    new 
query[128];
    
mysql_format(mysql_dbquerysizeof(query), "SELECT * FROM players;");
    
mysql_tquery(mysql_dbquery"CheckQuery1");
    new 
string[60];
    
//CheckQuery1();
    //printf("Number of Accounts: %d.", cache_get_row_count());
    
format(stringsizeof(string), "Number of Accounts: %d."cache_get_row_count());
    
SendClientMessage(playeridCOLOR_REDstring);
    return 
1;

I type /123 and it spams..


Re: Mysql Problem! - Jefff - 31.10.2015

pawn Код:
public CheckQuery1(playerid)
{
    static bool:OneTime;
    if(!OneTime)
    {
        OneTime = true;
        mysql_tquery(mysql_db, "SELECT * FROM players", "CheckQuery1", "i", playerid);
        return 1;
    }

    new string[60];
    //CheckQuery1();
    //printf("Number of Accounts: %d.", cache_get_row_count());
    format(string, sizeof(string), "Number of Accounts: %d.", cache_get_row_count());
    SendClientMessage(playerid, COLOR_RED, string);
    OneTime = false;
    return 1;
}



Re: Mysql Problem! - Macluawn - 31.10.2015

That`s called recursion https://en.wikipedia.org/wiki/Recursion

On line 5, mysql is instructed to call CheckQuery1 query, which in return calls the query again and again calls that callback and so on.
You have two choices:


Re: Mysql Problem! - PrO.GameR - 01.11.2015

You are simply making a loop > CheckQuery1 > sends a query which recalls CheckQuery1 > CheckQuery1 > sending another query .... > ---- ^
Why you don't simply put the query in the CMD and remove it from the function ?