PDA

View Full Version : Problem with loading houses to the server


FunnyBear
31/01/2015, 06:43 PM
Hi,

I've been trying to make a House System, but I'm stuck on loading the houses to the server. Here is the function,

forward LoadHouses();
public LoadHouses()
{
for(new i=1; i<=MAX_HOUSES; i++)
{
new query[256];
format(query, sizeof(query), "SELECT * FROM `"Houses_Table"` WHERE `ID` = '%i'", i);
mysql_query(query);
mysql_store_result();
if(mysql_num_rows() == 0) break;
else if(mysql_num_rows() != 0)
{
mysql_fetch_row_format(query);
sscanf(query, "e<p<|>is[25]iiiiiffffff>", hInfo[i]);
new lString[256];
if(hInfo[i][OnSale] == 0 )
{
switch(hInfo[i][Owned])
{
case 0:
{
format(lString, sizeof(lString), "House Owned: No\nHouse Owner: None\nHouse Price: $%i", hInfo[i][Price]);
hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0x00B9FFFF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0);
hInfo[i][Icon] = CreateDynamicMapIcon(hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], 31, -1);
hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0);
}
case 1:
{
format(lString, sizeof(lString),"House Owned: Yes\nHouse Owner: %s\nHouse Locked: %s", hInfo[i][Owner], (hInfo[i][Locked] == 1) ? ("Yes") : ("No"));
hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0xFF0000FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0);
//hInfo[i][Icon] = CreateDynamicMapIcon(hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], 32, -1);
hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0);
}
}
}
if(hInfo[i][Owned] == 1)
{
if(hInfo[i][OnSale] == 1)
{
format(lString, sizeof(lString),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse On Sale: Yes", hInfo[i][Owner], hInfo[i][Price]);
hInfo[i][Label] = CreateDynamic3DTextLabel(lString, 0xD65418FF, hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ]+0.5, 36.0);
hInfo[i][Icon] = CreateDynamicMapIcon(hInfo[i][OX], hInfo[i][OY], hInfo[i][OZ], 32, -1);
hInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0);
}
}
CreatedHouses++;
}
}
mysql_free_result();
printf("[House System] %i houses were created...", CreatedHouses);
return 1;
}

And I have LoadHouses(); under OnGameModeInit. I have around 10 houses saved to the database now. But when I start the server, it says 0 houses were created. And when I go ingame, there are no houses around. How can I fix this problem?

Thanks

Lynn
31/01/2015, 07:35 PM
format(query, sizeof(query), "SELECT * FROM `Houses_Table` WHERE `ID` = '%i'", i);

FunnyBear
31/01/2015, 07:49 PM
It's supposed to be like that

`"Houses_Table"`

I defined it at the top of the script

FunnyBear
31/01/2015, 09:57 PM
Any help?