MySQL results in dialog
#1

Hi, i have a small problem , i'am doing a Phone SMS system, when player do /t sms got a list of the SMS that will be loaded from the database, but the problem is when i do /t sms they got too many SMS query's and will not stop and still spamming it and server wil lag.

PHP код:
ListPlayerSMS(playerid)
{
    static
        
query[160];
    
format(query, sizeof(query), "SELECT * FROM `sms` WHERE `ReceivNumber` = %d", pInfo[playerid][pNumber]);
    return 
mysql_tquery(dbHandle, query, "OnSMSFind", "d", playerid);
} 
PHP код:
public OnSMSFind(playerid)
{
    new 
desc[255], numbersender, string[1024];
    new 
rows = cache_num_rows();
    if(
rows)
    {
        new 
loaded;
        while(
loaded < rows)
        {
            
numbersender = cache_get_field_content_int(loaded, "SmsNumber");
            
cache_get_field_content(loaded, "Text", desc, 255);
            
format(string, sizeof(string), "%s SMS from : {2ECC71}%d : {FFFFFF}%s\n", string, numbersender, desc);
        }
        
Dialog_Show(playerid, DialogSMS, DIALOG_STYLE_TABLIST,"My SMS",string,"Close","");
    }
    else return 
Server(playerid, "You don't have any SMS.");
    return 
1;
} 
Reply
#2

Quote:
Originally Posted by AlexBlack
Посмотреть сообщение
Hi, i have a small problem , i'am doing a Phone SMS system, when player do /t sms got a list of the SMS that will be loaded from the database, but the problem is when i do /t sms they got too many SMS query's and will not stop and still spamming it and server wil lag.

PHP код:
ListPlayerSMS(playerid)
{
    static
        
query[160];
    
format(query, sizeof(query), "SELECT * FROM `sms` WHERE `ReceivNumber` = %d", pInfo[playerid][pNumber]);
    return 
mysql_tquery(dbHandle, query, "OnSMSFind", "d", playerid);
} 
PHP код:
public OnSMSFind(playerid)
{
    new 
desc[255], numbersender, string[1024];
    new 
rows = cache_num_rows();
    if(
rows)
    {
        new 
loaded;
        while(
loaded < rows)
        {
            
numbersender = cache_get_field_content_int(loaded, "SmsNumber");
            
cache_get_field_content(loaded, "Text", desc, 255);
            
format(string, sizeof(string), "%s SMS from : {2ECC71}%d : {FFFFFF}%s\n", string, numbersender, desc);
        }
        
Dialog_Show(playerid, DialogSMS, DIALOG_STYLE_TABLIST,"My SMS",string,"Close","");
    }
    else return 
Server(playerid, "You don't have any SMS.");
    return 
1;
} 
Try doing something along the lines of this. (BlueG MySQL R39-3)

pawn Код:
if(cache_get_row_count(/* CONNECTION VAR HERE */))
{
    for(new i = 0; i < cache_get_row_count(/* CONNECTION VAR HERE */); i ++)
    {
                  // Code here
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)