[13:33:59] [DEBUG] cache_get_data - connection: 1 [13:33:59] [WARNING] cache_get_data - no active cache [13:33:59] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM `houses` WHERE `ID` = '0'", callback: "OnLoadHouses", format: "(null)" [13:33:59] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [13:33:59] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [13:33:59] [DEBUG] CMySQLConnection::Connect - establishing connection to database... [13:33:59] [DEBUG] CMySQLConnection::Connect - connection was successful [13:33:59] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [13:33:59] [DEBUG] CMySQLQuery::Execute[OnLoadHouses] - starting query execution [13:33:59] [DEBUG] CMySQLConnection::Connect - connection was successful [13:33:59] [DEBUG] CMySQLQuery::Execute[OnLoadHouses] - query was successfully executed within 0.413 milliseconds [13:33:59] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [13:33:59] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [13:33:59] [DEBUG] Calling callback "OnLoadHouses".. [13:33:59] [DEBUG] cache_get_data - connection: 1 [13:33:59] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called |
stock LoadHouses()
{
new rows, fields, result[5], query[300];
cache_get_data(rows, fields);
if(rows)
{
cache_get_field_content(0, "ID", result);
g_HouseInfo[HouseID][hSQLid] = strval(result);
}
format(query, sizeof query, "SELECT * FROM `houses` WHERE `ID` = '%d'", HouseID);
mysql_function_query(g_Handle, query, true, "OnLoadHouses", "");
return 1;
}
forward OnLoadHouses();
public OnLoadHouses()
{
new rows, fields, result[129], string[128];
cache_get_data(rows, fields);
if(rows != 0)
{
cache_get_field_content(0, "Owner", result), format(g_HouseInfo[HouseID][hOwner], 24, result);
cache_get_field_content(0, "OwnerID", result), g_HouseInfo[HouseID][hOwnerid] = strval(result);
cache_get_field_content(0, "EnPosX", result), g_HouseInfo[HouseID][hEnPosX] = floatstr(result);
cache_get_field_content(0, "EnPosY", result), g_HouseInfo[HouseID][hEnPosY] = floatstr(result);
cache_get_field_content(0, "EnPosZ", result), g_HouseInfo[HouseID][hEnPosZ] = floatstr(result);
cache_get_field_content(0, "ExPosX", result), g_HouseInfo[HouseID][hExPosX] = floatstr(result);
cache_get_field_content(0, "ExPosY", result), g_HouseInfo[HouseID][hExPosY] = floatstr(result);
cache_get_field_content(0, "ExPosZ", result), g_HouseInfo[HouseID][hExPosZ] = floatstr(result);
cache_get_field_content(0, "Interior", result), g_HouseInfo[HouseID][hInterior] = strval(result);
cache_get_field_content(0, "World", result), g_HouseInfo[HouseID][hWorld] = strval(result);
cache_get_field_content(0, "Pickup", result), g_HouseInfo[HouseID][hPickup] = strval(result);
cache_get_field_content(0, "Price", result), g_HouseInfo[HouseID][hPrice] = strval(result);
cache_get_field_content(0, "Locked", result), g_HouseInfo[HouseID][hLocked] = strval(result);
cache_get_field_content(0, "StreetName", result), format(g_HouseInfo[HouseID][hStreetName], 64, result);
cache_get_field_content(0, "LabelID", result), _:g_HouseInfo[HouseID][hLabel] = strval(result);
HouseID++;
}
if(g_HouseInfo[HouseID][hOwned] == 0)
{
format(string, sizeof(string), "STREET NOT SET\nResidence of The State\nPrice: $%d", g_HouseInfo[HouseID][hPrice]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1273, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
if(g_HouseInfo[HouseID][hOwned] == 1)
{
format(string, sizeof(string), "%s\nResidence of %s", g_HouseInfo[HouseID][hStreetName], g_HouseInfo[HouseID][hOwner]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1318, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
g_HouseInfo[HouseID][hLabel] = CreateDynamic3DTextLabel(string, -1, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
printf("> %d houses have been loaded from the database.", HouseID);
return 1;
}
forward OnLoadHouses();
public OnLoadHouses()
{
new rows, fields, result[129], string[128];
cache_get_data(rows, fields);
if(!rows)
{
print(!"No houses found!");
return true;
}
for(new i = 0; i != rows; i++)
{
cache_get_field_content(i, "Owner", result), format(g_HouseInfo[HouseID][hOwner], 24, result);
cache_get_field_content(i, "OwnerID", result), g_HouseInfo[HouseID][hOwnerid] = strval(result);
cache_get_field_content(i, "EnPosX", result), g_HouseInfo[HouseID][hEnPosX] = floatstr(result);
cache_get_field_content(i, "EnPosY", result), g_HouseInfo[HouseID][hEnPosY] = floatstr(result);
cache_get_field_content(i, "EnPosZ", result), g_HouseInfo[HouseID][hEnPosZ] = floatstr(result);
cache_get_field_content(i, "ExPosX", result), g_HouseInfo[HouseID][hExPosX] = floatstr(result);
cache_get_field_content(i, "ExPosY", result), g_HouseInfo[HouseID][hExPosY] = floatstr(result);
cache_get_field_content(i, "ExPosZ", result), g_HouseInfo[HouseID][hExPosZ] = floatstr(result);
cache_get_field_content(i, "Interior", result), g_HouseInfo[HouseID][hInterior] = strval(result);
cache_get_field_content(i, "World", result), g_HouseInfo[HouseID][hWorld] = strval(result);
cache_get_field_content(i, "Pickup", result), g_HouseInfo[HouseID][hPickup] = strval(result);
cache_get_field_content(i, "Price", result), g_HouseInfo[HouseID][hPrice] = strval(result);
cache_get_field_content(i, "Locked", result), g_HouseInfo[HouseID][hLocked] = strval(result);
cache_get_field_content(i, "StreetName", result), format(g_HouseInfo[HouseID][hStreetName], 64, result);
cache_get_field_content(i, "LabelID", result), _:g_HouseInfo[HouseID][hLabel] = strval(result);
HouseID++;
if(g_HouseInfo[HouseID][hOwned] == 0)
{
format(string, sizeof(string), "STREET NOT SET\nResidence of The State\nPrice: $%d", g_HouseInfo[HouseID][hPrice]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1273, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
if(g_HouseInfo[HouseID][hOwned] == 1)
{
format(string, sizeof(string), "%s\nResidence of %s", g_HouseInfo[HouseID][hStreetName], g_HouseInfo[HouseID][hOwner]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1318, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
g_HouseInfo[HouseID][hLabel] = CreateDynamic3DTextLabel(string, -1, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
}
printf("> %d houses have been loaded from the database.", HouseID);
return 1;
}
CMD:createhouse(playerid, params[])
{
if(g_PlayerInfo[playerid][pAdmin] == 6 && g_AdminLogged[playerid] == 1)
{
new
string[128],
query[300],
Float:x,
Float:y,
Float:z;
HouseID++;
format(string, sizeof(string), "STREET NOT SET\nResidence of The State\nPrice: $%d", g_HouseInfo[HouseID][hPrice]);
GetPlayerPos(playerid, x, y, z);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1273, 23, x, y, z, 0, 0, -1, 250);
g_HouseInfo[HouseID][hLabel] = CreateDynamic3DTextLabel(string, -1, x, y, z, 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
format(string, sizeof(string), "House ID: %d created", HouseID);
SendClientMessage(playerid, -1, string);
g_HouseInfo[HouseID][hWorld] = HouseID;
format(query, sizeof(query), "INSERT INTO `Houses` (ID, Owner, Owned, OwnerID, EnPosX, EnPosY, EnPosZ, \
Interior, World, Pickup, Price, Locked, StreetName, LabelID) \
VALUES('%i', 'The State', '0', '499', '%f', '%f', '%f', '0', '%d', '1273', '500000', '1', 'Default', '%d')",
HouseID, x, y, z, g_HouseInfo[HouseID][hWorld], _:g_HouseInfo[HouseID][hLabel]);
mysql_function_query(g_Handle, query, false, "SendQuery", "");
} else return SendClientMessage(playerid, -1, "SERVER: You are not authorized to use this command.");
return 1;
}
SELECT * FROM `houses`
SELECT * FROM `houses` LIMIT 0,max_houses
Hm, no I don't seem to have any callback for checking the HouseID's, would you care to help me out?
|
INSERT INTO `Houses` (Owner, Owned, OwnerID, EnPosX, EnPosY, EnPosZ, Interior, World, Pickup, Price, Locked, StreetName, LabelID) VALUES('The State', '0', '499', '%f', '%f', '%f', '0', '%d', '1273', '500000', '1', 'Default', '%d'
stock LoadHouses()
{
mysql_function_query(g_Handle, "SELECT * FROM `houses`", true, "OnLoadHouses", "");
}
forward OnLoadHouses();
public OnLoadHouses()
{
new rows, fields, result[129], string[128];
cache_get_data(rows, fields);
if(!rows)
{
print(!"No houses found!");
return true;
}
for(new i = 0; i != rows; i++)
{
cache_get_field_content(i, "ID", HouseID);
cache_get_field_content(i, "Owner", result), format(g_HouseInfo[HouseID][hOwner], 24, result);
cache_get_field_content(i, "OwnerID", result), g_HouseInfo[HouseID][hOwnerid] = strval(result);
cache_get_field_content(i, "EnPosX", result), g_HouseInfo[HouseID][hEnPosX] = floatstr(result);
cache_get_field_content(i, "EnPosY", result), g_HouseInfo[HouseID][hEnPosY] = floatstr(result);
cache_get_field_content(i, "EnPosZ", result), g_HouseInfo[HouseID][hEnPosZ] = floatstr(result);
cache_get_field_content(i, "ExPosX", result), g_HouseInfo[HouseID][hExPosX] = floatstr(result);
cache_get_field_content(i, "ExPosY", result), g_HouseInfo[HouseID][hExPosY] = floatstr(result);
cache_get_field_content(i, "ExPosZ", result), g_HouseInfo[HouseID][hExPosZ] = floatstr(result);
cache_get_field_content(i, "Interior", result), g_HouseInfo[HouseID][hInterior] = strval(result);
cache_get_field_content(i, "World", result), g_HouseInfo[HouseID][hWorld] = strval(result);
cache_get_field_content(i, "Pickup", result), g_HouseInfo[HouseID][hPickup] = strval(result);
cache_get_field_content(i, "Price", result), g_HouseInfo[HouseID][hPrice] = strval(result);
cache_get_field_content(i, "Locked", result), g_HouseInfo[HouseID][hLocked] = strval(result);
cache_get_field_content(i, "StreetName", result), format(g_HouseInfo[HouseID][hStreetName], 64, result);
cache_get_field_content(i, "LabelID", result), _:g_HouseInfo[HouseID][hLabel] = strval(result);
if(g_HouseInfo[HouseID][hOwned] == 0)
{
format(string, sizeof(string), "STREET NOT SET\nResidence of The State\nPrice: $%d", g_HouseInfo[HouseID][hPrice]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1273, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
if(g_HouseInfo[HouseID][hOwned] == 1)
{
format(string, sizeof(string), "%s\nResidence of %s", g_HouseInfo[HouseID][hStreetName], g_HouseInfo[HouseID][hOwner]);
g_HouseInfo[HouseID][hPickup] = CreateDynamicPickup(1318, 23, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 0, 0, -1, 250);
}
g_HouseInfo[HouseID][hLabel] = CreateDynamic3DTextLabel(string, -1, g_HouseInfo[HouseID][hEnPosX], g_HouseInfo[HouseID][hEnPosY], g_HouseInfo[HouseID][hEnPosZ], 100, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 10.0);
}
printf("> %d houses have been loaded from the database.", HouseID);
return 1;
}