enum oInfo
{
modelid,
Float:X,
Float:Y,
Float:Z,
Float:rX,
Float:rY,
Float:rZ
};
new object [ 2000 ][ oInfo ];
stock laodObjects(playerid)
{
mysql_format(db, query, sizeof(query), "SELECT * FROM `objects`");
mysql_pquery(db, query, "loadObjects", "d", sizeof(object));
}
forward loadObjects();
public loadObjects()
{
new count = 0, rows, fields;
cache_get_data(rows, fields, db);
for(new i; i < rows; i++)
{
for(new o; o < sizeof(object); o++)
{
object[o][modelid] = cache_get_field_content_int(i, "modelid");
object[o][X] = cache_get_field_content_float(i, "X");
object[o][Y] = cache_get_field_content_float(i, "Y");
object[o][Z] = cache_get_field_content_float(i, "Z");
object[o][rX] = cache_get_field_content_float(i, "rX");
object[o][rY] = cache_get_field_content_float(i, "rY");
object[o][rZ] = cache_get_field_content_float(i, "rZ");
CreateDynamicObject(object[o][modelid], object[o][X], object[o][Y], object[o][Z], object[o][rX], object[o][rY], object[o][rZ]);
count++;
break;
}
}
printf("Loaded objects from MySQL: %d", count);
return 1;
}
rows = clamp(rows, 0, sizeof object - 1);
for (new o; o < rows; o++)
{
object[o][modelid] = cache_get_field_content_int(o, "modelid");
object[o][X] = cache_get_field_content_float(o, "X");
object[o][Y] = cache_get_field_content_float(o, "Y");
object[o][Z] = cache_get_field_content_float(o, "Z");
object[o][rX] = cache_get_field_content_float(o, "rX");
object[o][rY] = cache_get_field_content_float(o, "rY");
object[o][rZ] = cache_get_field_content_float(o, "rZ");
CreateDynamicObject(object[o][modelid], object[o][X], object[o][Y], object[o][Z], object[o][rX], object[o][rY], object[o][rZ]);
}
printf("Loaded objects from MySQL: %d", rows);
stock laodObjects(playerid)
{
mysql_format(db, query, sizeof(query), "SELECT * FROM `objects`");
mysql_pquery(db, query, "loadObjects", "d", sizeof(object));
}
mysql_pquery(db, query, "loadObjects", "d", sizeof(object));
Alright thanks for helping me i will test it as soon as i reach my home.. i am on highway right now :P
Ok but i didnt understand diffrence of PHP код:
Thank you to help me. you deserve +rep too. |
stock laodObjects(playerid) //select what you need
{
mysql_format(db, query, sizeof(query), "SELECT * FROM `objects`");
mysql_pquery(db, query, "loadObjects2", "d", sizeof(object));
}
forward loadObjects2();
public loadObjects2() //do what you need with selected stuff
{
//...
}
and also in place of db in above stock i have to use my DB right?
|
db = mysql_connect(M_Host, M_User, M_Data, M_Pass);
How to set auto increment in Object ID? like while loading and saving?
rows = clamp(rows, 0, sizeof object - 1);