14.05.2014, 10:15
Hi, I've attempted to make a MySQL housing system.
This is my LoadHouses function
For testing, I created 1 house ingame. When I tried tried to retrieve the houses, It retrieved the first house. That was good. But, It started to check for unknown houses. The table only has 1 house. But, It looks till 500 houses.
It's spamming my mysql_log.txt.
This is my LoadHouses function
pawn Код:
public LoadHouses()
{
for(new i=1; i<MAX_HOUSES; i++)
{
format(gQuery,sizeof gQuery,"SELECT * FROM `"Houses_Table"` WHERE `HouseID` = '%i'",i);
mysql_query(gQuery);
mysql_store_result();
if(mysql_num_rows() == 1)
{
mysql_fetch_row_format(gQuery);
sscanf(gQuery,"e<p<|>iiis[25]iiffffff>",HouseInfo[i]);
mysql_free_result();
new lString[256];
switch(HouseInfo[i][hOwned])
{
case 0:
{
CreateDynamicMapIcon(HouseInfo[i][OutX], HouseInfo[i][OutY], HouseInfo[i][OutZ], 31, -1);
format(lString,sizeof(lString),"House Owned: No\nHouse Price: $%i\n",HouseInfo[i][hPrice]);
HouseInfo[i][Label] = CreateDynamic3DTextLabel(lString,COLOR_RED,HouseInfo[i][OutX],HouseInfo[i][OutY],HouseInfo[i][OutZ]+1.5,50.0);
HouseInfo[i][HouseEnterCP] = CreateDynamicCP(HouseInfo[i][OutX],HouseInfo[i][OutY],HouseInfo[i][OutZ],1.5,-1,-1,-1,50.0);
}
case 1:
{
CreateDynamicMapIcon(HouseInfo[i][OutX], HouseInfo[i][OutY], HouseInfo[i][OutZ], 32, -1);
format(lString,sizeof(lString),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\n",HouseInfo[i][hOwner],HouseInfo[i][hPrice]);
HouseInfo[i][Label] = CreateDynamic3DTextLabel(lString,COLOR_RED,HouseInfo[i][OutX],HouseInfo[i][OutY],HouseInfo[i][OutZ]+1.5,50.0);
HouseInfo[i][HouseEnterCP] = CreateDynamicCP(HouseInfo[i][OutX],HouseInfo[i][OutY],HouseInfo[i][OutZ],1.5,-1,-1,-1,50.0);
HouseInfo[i][HouseExitCP] = CreateDynamicCP(HouseInfo[i][IntX],HouseInfo[i][IntY],HouseInfo[i][IntZ],1.5,-1,-1,-1,20.0);
}
}
HousesCreated++;
}
}
mysql_free_result();
printf("The server has retrieved %i houses from the database!",HousesCreated);
return 1;
}
It's spamming my mysql_log.txt.