forward LoadHouses(); public LoadHouses() { new rows; cache_get_row_count(rows); if(rows) { new id, loaded; for(new i = 0; i < rows; i++) { cache_get_value_name_int(loaded, "ID", id); cache_get_value_name_float(loaded, "EnterX", hInfo[id][hEnterX]); cache_get_value_name_float(loaded, "EnterY", hInfo[id][hEnterY]); cache_get_value_name_float(loaded, "EnterZ", hInfo[id][hEnterZ]); cache_get_value_name_float(loaded, "ExitX", hInfo[id][hExitX]); cache_get_value_name_float(loaded, "ExitX", hInfo[id][hExitY]); cache_get_value_name_float(loaded, "ExitY", hInfo[id][hExitZ]); cache_get_value_name_float(loaded, "ExitZ", hInfo[id][hExitX]); cache_get_value_name_int(loaded, "InsideInt", hInfo[id][hInsideInt]); cache_get_value_name_int(loaded, "InsideVir", hInfo[id][hInsideVir]); cache_get_value_name_int(loaded, "OutsideInt", hInfo[id][hOutsideInt]); cache_get_value_name_int(loaded, "Level", hInfo[id][hLevel]); cache_get_value_name(loaded, "Owner", hInfo[id][hOwner], 48); cache_get_value_name_int(loaded, "Price", hInfo[id][hPrice]); new string[255]; format(string, sizeof(string), "House %d, x: %d, y:%d, z:%d", id, hInfo[id][hEnterX], hInfo[id][hEnterY], hInfo[id][hEnterZ]); print(string); loaded++; hInfo[id][hPickup] = CreatePickup(1273, 0, hInfo[id][hEnterX], hInfo[id][hEnterY], hInfo[id][hEnterZ], -1); } new string[255]; format(string, sizeof(string), "Loaded %d houses from Database.", rows); print(string); } else { print("No house loaded on Database."); return 1; } return 1; }
I tried with virtual world 0 and it's not working, i will test with createdynamicpickup
|
CreatePickup(1273, 1, hInfo[id][hEnterX], hInfo[id][hEnterY], hInfo[id][hEnterZ], -1);
format(string, sizeof(string), "House %d, x: %d, y:%d, z:%d", id, hInfo[id][hEnterX], hInfo[id][hEnterY], hInfo[id][hEnterZ]);
forward LoadHouses();
public LoadHouses()
{
new rows;
cache_get_row_count(rows);
new Float:X, Float:Y, Float:Z;
if(rows)
{
new id, loaded;
for(new i = 0; i < rows; i++) {
cache_get_value_name_int(loaded, "ID", id);
cache_get_value_name_float(loaded, "EnterX", hInfo[id][hEnterX]);
cache_get_value_name_float(loaded, "EnterY", hInfo[id][hEnterY]);
cache_get_value_name_float(loaded, "EnterZ", hInfo[id][hEnterZ]);
cache_get_value_name_float(loaded, "ExitX", hInfo[id][hExitX]);
cache_get_value_name_float(loaded, "ExitX", hInfo[id][hExitY]);
cache_get_value_name_float(loaded, "ExitY", hInfo[id][hExitZ]);
cache_get_value_name_float(loaded, "ExitZ", hInfo[id][hExitX]);
cache_get_value_name_int(loaded, "InsideInt", hInfo[id][hInsideInt]);
cache_get_value_name_int(loaded, "InsideVir", hInfo[id][hInsideVir]);
cache_get_value_name_int(loaded, "OutsideInt", hInfo[id][hOutsideInt]);
cache_get_value_name_int(loaded, "Level", hInfo[id][hLevel]);
cache_get_value_name(loaded, "Owner", hInfo[id][hOwner], 48);
cache_get_value_name_int(loaded, "Price", hInfo[id][hPrice]);
X = hInfo[id][hEnterX];
Y = hInfo[id][hEnterY];
Z = hInfo[id][hEnterZ];
new string[255];
format(string, sizeof(string), "House %d, x: %d, y:%d, z:%d", id, hInfo[id][hEnterX], hInfo[id][hEnterY], hInfo[id][hEnterZ]);
print(string);
loaded++;
hInfo[id][hPickup] = CreatePickup(1273, 0, X, Y, Z, -1);
}
new string[255];
format(string, sizeof(string), "Loaded %d houses from Database.", rows);
print(string);
}
else
{
print("No house loaded on Database.");
return 1;
}
return 1;
}
CMD:addhouse(playerid, params[]) { new model; if(sscanf(params, "d", model)) return SendClientMessage(playerid, COLOR_WHITE, ""dr"Usage: "w"/addhouse [1-small 2-medium 3-big]"); if(model > 3 || model < 1) return SendClientMessage(playerid, COLOR_WHITE, ""dr"Usage: "w"/addhouse [1-small 2-medium 3-big]"); new Float:px, Float:py, Float:pz, Float:pinterior; GetPlayerPos(playerid, px, py, pz); pinterior = GetPlayerInterior(playerid); if(model == 1) { new randomsmall = random(sizeof(SmallHouses)); new DB_Query[600]; mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `HOUSES` (`EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `InsideInt`, `OutsideInt`, `Level`, `Owner`, `Price`) \ VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', 'None', '%d')", \ px, py, pz, SmallHouses[randomsmall][EH_X], SmallHouses[randomsmall][EH_Y], SmallHouses[randomsmall][EH_Z], SmallHouses[randomsmall][EH_Interior], pinterior, 5, 50000000, 1, 1); mysql_query(Database, DB_Query); mysql_query(Database, "SELECT * FROM `HOUSES`"); new rows = cache_num_rows(); new string[255]; format(string, sizeof(string), ""dr"Small House added (%d) at %d, %d, %d", rows, px, py, pz); SendClientMessage(playerid, COLOR_WHITE, string); LoadHouses(); return 1; }
Oh, the coords are not correct, if i check my position, for example is:
1941.3182, 1314.4194, 9.2578 and in database is 1156753967, 1151618412, 1091837952 The /addhouse command: Код:
CMD:addhouse(playerid, params[]) { new model; if(sscanf(params, "d", model)) return SendClientMessage(playerid, COLOR_WHITE, ""dr"Usage: "w"/addhouse [1-small 2-medium 3-big]"); if(model > 3 || model < 1) return SendClientMessage(playerid, COLOR_WHITE, ""dr"Usage: "w"/addhouse [1-small 2-medium 3-big]"); new Float:px, Float:py, Float:pz, Float:pinterior; GetPlayerPos(playerid, px, py, pz); pinterior = GetPlayerInterior(playerid); if(model == 1) { new randomsmall = random(sizeof(SmallHouses)); new DB_Query[600]; mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `HOUSES` (`EnterX`, `EnterY`, `EnterZ`, `ExitX`, `ExitY`, `ExitZ`, `InsideInt`, `OutsideInt`, `Level`, `Owner`, `Price`) \ VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', 'None', '%d')", \ px, py, pz, SmallHouses[randomsmall][EH_X], SmallHouses[randomsmall][EH_Y], SmallHouses[randomsmall][EH_Z], SmallHouses[randomsmall][EH_Interior], pinterior, 5, 50000000, 1, 1); mysql_query(Database, DB_Query); mysql_query(Database, "SELECT * FROM `HOUSES`"); new rows = cache_num_rows(); new string[255]; format(string, sizeof(string), ""dr"Small House added (%d) at %d, %d, %d", rows, px, py, pz); SendClientMessage(playerid, COLOR_WHITE, string); LoadHouses(); return 1; } |
VALUES ('%f', '%f', '%f', '%d', '%d', '%d', '%d', '%d', '%d', 'None', '%d')", \
px, py, pz, SmallHouses[randomsmall][EH_X], SmallHouses[randomsmall][EH_Y], SmallHouses[randomsmall][EH_Z], SmallHouses[randomsmall][EH_Interior], pinterior, 5, 50000000, 1, 1);