forward OnLoadATMS();
public OnLoadATMS()
{
new string[512], i;
new rows, fields;
cache_get_data(rows, fields, MainPipeline);
while(i<rows)
{
for(new field;field<fields;field++)
{
cache_get_row(i, field, string, MainPipeline);
switch(field)
{
case 1: ATM[i][atmVW] = strval(string);
case 2: ATM[i][atmInt] = strval(string);
case 3: ATM[i][atmModelz] = strval(string);
case 4: ATM[i][atmPosX] = floatstr(string);
case 5: ATM[i][atmPosY] = floatstr(string);
case 6: ATM[i][atmPosZ] = floatstr(string);
case 7: ATM[i][atmAngle] = floatstr(string);
}
}
RenderATM(i);
i++;
}
if(i > 0) printf("[LoadATMS] %d atms rehashed/loaded.", i);
else printf("[LoadATMS] Failed to load any atms.");
return 1;
}
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 houses rehashed/loaded.", i);
else printf("[LoadATMS] Failed to load any houses.");
}
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);
}
stock RenderATM(id)
{
DestroyDynamicObject(ATM[id][atmObjectId]);
DestroyDynamic3DTextLabel(ATM[id][atmTextId]);
if(ATM[id][atmPosX] != 0.0)
{
new string[128];
ATM[id][atmObjectId] = CreateDynamicObject(2942, ATM[id][atmPosX], ATM[id][atmPosY], ATM[id][atmPosZ], 0.0, 0.0, ATM[id][atmAngle], ATM[id][atmVW], ATM[id][atmInt], .streamdistance = 100.0);
format(string,sizeof(string),"ATM (ID: %d)\nType /awithdraw or /adeposit to transfer cash.", id);
ATM[id][atmTextId] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, ATM[id][atmPosX], ATM[id][atmPosY], ATM[id][atmPosZ] + 0.5, 10.0, .worldid = ATM[id][atmVW], .testlos = 0, .streamdistance = 25.0);
}
}
enum atmInfo
{
atmVW,
atmInt,
atmModelz,
Float: atmPosX,
Float: atmPosY,
Float: atmPosZ,
Float: atmAngle,
atmObjectId,
Text3D: atmTextId
}
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++;
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(ATM[id][atmPosX] == 0.0) {
return SendClientMessageEx(playerid, COLOR_GRAD2, "No atms found with that ID.");
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 houses rehashed/loaded.", i);
else printf("[LoadATMS] Failed to load any houses.");
}
forward OnLoadATMS();
public OnLoadATMS()
{
new i, rows, fields;
cache_get_data(rows, fields, MainPipeline);
while(i < rows)
{
ATM[i][atmVW] = cache_get_field_content_int(i, "VW", MainPipeline);
ATM[i][atmInt] = cache_get_field_content_int(i, "Int", MainPipeline);
ATM[i][atmModelz] = cache_get_field_content_int(i, "Modelz", MainPipeline);
ATM[i][atmPosX] = cache_get_field_content_float(i, "PosX", MainPipeline);
ATM[i][atmPosY] = cache_get_field_content_float(i, "PosY", MainPipeline);
ATM[i][atmPosZ] = cache_get_field_content_float(i, "PosZ", MainPipeline);
ATM[i][atmAngle] = cache_get_field_content_float(i, "Angle", MainPipeline);
RenderATM(i);
i++;
}
if(i > 0) printf("[LoadATMS] %d houses rehashed/loaded.", i);
else printf("[LoadATMS] Failed to load any houses.");
}
Also why aren't you using the natives cache_get_field_content_int() and cache_get_field_content_float()
|