Mysql Problem!
#1

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..
Reply
#2

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;
}
Reply
#3

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:
  • Create a stopping condition, as demonstrated by Jeff.
  • Move the callback to a different function, which does not call this query.
Reply
#4

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 ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)