SA-MP Forums Archive
MySQL results in dialog - 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 results in dialog (/showthread.php?tid=583846)



MySQL results in dialog - AlexBlack - 31.07.2015

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(querysizeof(query), "SELECT * FROM `sms` WHERE `ReceivNumber` = %d"pInfo[playerid][pNumber]);
    return 
mysql_tquery(dbHandlequery"OnSMSFind""d"playerid);

PHP код:
public OnSMSFind(playerid)
{
    new 
desc[255], numbersenderstring[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"desc255);
            
format(stringsizeof(string), "%s SMS from : {2ECC71}%d : {FFFFFF}%s\n"stringnumbersenderdesc);
        }
        
Dialog_Show(playeridDialogSMSDIALOG_STYLE_TABLIST,"My SMS",string,"Close","");
    }
    else return 
Server(playerid"You don't have any SMS.");
    return 
1;




Re: MySQL results in dialog - zT KiNgKoNg - 31.07.2015

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(querysizeof(query), "SELECT * FROM `sms` WHERE `ReceivNumber` = %d"pInfo[playerid][pNumber]);
    return 
mysql_tquery(dbHandlequery"OnSMSFind""d"playerid);

PHP код:
public OnSMSFind(playerid)
{
    new 
desc[255], numbersenderstring[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"desc255);
            
format(stringsizeof(string), "%s SMS from : {2ECC71}%d : {FFFFFF}%s\n"stringnumbersenderdesc);
        }
        
Dialog_Show(playeridDialogSMSDIALOG_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
    }
}