stock LoadATMS()
{
printf("[LoadAtms] Loading data from database...");
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadAtms", "");
}
forward OnLoadATMS();
public OnLoadATMS()
{
new i, rows, fields, tmp[128];
cache_get_data(rows, fields, MainPipeline);
while(i < rows)
{
cache_get_field_content(i, "VW", tmp, MainPipeline); ATM[i][atmVW] = strval(tmp);
cache_get_field_content(i, "Int", tmp, MainPipeline); ATM[i][atmInt] = strval(tmp);
cache_get_field_content(i, "Modelz", tmp, MainPipeline); ATM[i][atmModelz] = strval(tmp);
cache_get_field_content(i, "PosX", tmp, MainPipeline); ATM[i][atmPosX] = floatstr(tmp);
cache_get_field_content(i, "PosY", tmp, MainPipeline); ATM[i][atmPosY] = floatstr(tmp);
cache_get_field_content(i, "PosZ", tmp, MainPipeline); ATM[i][atmPosZ] = floatstr(tmp);
cache_get_field_content(i, "Angle", tmp, MainPipeline); ATM[i][atmAngle] = floatstr(tmp);
RenderATM(i);
i++;
}
if(i > 0) printf("[LoadATMS] %d atms rehashed/loaded.", i);
else printf("[LoadATMS] Failed to load any atms.");
}
stock SaveATM(id)
{
new string[512];
format(string, sizeof(string), "UPDATE `atms` SET \
`VW`=%d, \
`Int`=%d, \
`Modelz`=%d, \
`PosX`=%f, \
`PosY`=%f, \
`PosZ`=%f, \
`Angle`=%f WHERE `id`=%d",
ATM[id][atmVW],
ATM[id][atmInt],
ATM[id][atmModelz],
ATM[id][atmPosX],
ATM[id][atmPosY],
ATM[id][atmPosZ],
ATM[id][atmAngle],
id+1
); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
}
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadAtms", "");
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadATMS", "");
Programming languages are case sensitive, meaning that if you are calling OnLoadAtms but you have forwarded OnLoadATMS the script will simply not find the callback and will skip executing it while OnLoadATMS will not even be called. To fix that replace this:
Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadAtms", ""); Код:
mysql_function_query(MainPipeline, "SELECT * FROM `atms`", true, "OnLoadATMS", ""); |