Problem with Loop - 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: Problem with Loop (
/showthread.php?tid=611705)
Problem with Loop -
iWindows - 10.07.2016
I'm having a problem with a looping, it shows only the last ID of table, someone can help me?
Код:
stock VerLogsArmas(playerid)
{
new
string[128],
factionid = PlayerData[playerid][pFaction];
format(string, sizeof(string), "SELECT * FROM `zLogFaccaoID%d` ORDER BY 'ID' DESC", FactionData[factionid][factionID]);
mysql_tquery(g_iHandle, string, "OnViewLogsArmas", "d", playerid);
return 1;
}
forward OnViewLogsArmas(extraid, name[]);
public OnViewLogsArmas(extraid, name[])
{
new
string[1024],
nome[24],
arma[32],
data[64],
rows,
fields;
cache_get_data(rows, fields, g_iHandle);
if (!rows)
return SendErrorMessage(extraid, "Nenhum registro encontrado!");
for (new i = 0; i < rows; i ++) {
cache_get_field_content(i, "Data", data, g_iHandle, sizeof(data));
cache_get_field_content(i, "Nome", nome, g_iHandle, sizeof(nome));
cache_get_field_content(i, "Arma", arma, g_iHandle, sizeof(arma));
format(string, sizeof(string), "{FFFFFF}[%s] %s pegou uma %s \n", data, nome, arma);
}
Dialog_Show(extraid, ShowOnly, DIALOG_STYLE_LIST, "Registros de Armas", string, "Fechar", "");
return 1;
}
Re: Problem with Loop -
J0sh... - 10.07.2016
PHP код:
stock VerLogsArmas(playerid)
{
new
string[128],
factionid = PlayerData[playerid][pFaction];
format(string, sizeof(string), "SELECT * FROM `zLogFaccaoID%d` ORDER BY 'ID' DESC", FactionData[factionid][factionID]);
mysql_tquery(g_iHandle, string, "OnViewLogsArmas", "d", playerid);
return 1;
}
forward OnViewLogsArmas(extraid, name[]);
public OnViewLogsArmas(extraid, name[])
{
new
string[1024],
nome[24],
arma[32],
data[64],
rows,
fields;
cache_get_data(rows, fields, g_iHandle);
if (!rows)
return SendErrorMessage(extraid, "Nenhum registro encontrado!");
for (new i = 0; i < rows; i ++) {
cache_get_field_content(i, "Data", data, g_iHandle, sizeof(data));
cache_get_field_content(i, "Nome", nome, g_iHandle, sizeof(nome));
cache_get_field_content(i, "Arma", arma, g_iHandle, sizeof(arma));
format(string, sizeof(string), "%s{FFFFFF}[%s] %s pegou uma %s \n", string, data, nome, arma);
}
Dialog_Show(extraid, ShowOnly, DIALOG_STYLE_LIST, "Registros de Armas", string, "Fechar", "");
return 1;
}
You was resetting the string every row.