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(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;
}
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(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
}
}