Houses not loading (MySQL) -
FunnyBear - 07.03.2015
Hey,
I'm trying to fix a problem which I've had for atleast a month now. It's a problem with the load house function, and the houses do not load, however it does print how many houses have been found in the database to the console. I use MySQL R33.
Here is the loadhouse function,
Код:
forward LoadHouses();
public LoadHouses()
{
mysql_tquery(mysql, "SELECT * FROM `"HouseTable"`", "OnLoadHouses", "");
return 1;
}
forward OnLoadHouses();
public OnLoadHouses()
{
for(new i = 1; i <= cache_get_row_count(); i++)
{
new
savingstring[400];
cache_get_field_content(0, "ID", savingstring), hInfo[i][HID] = strval(savingstring);
cache_get_field_content(0, "Owner", hInfo[i][HID], mysql);
cache_get_field_content(0, "Owned", savingstring), hInfo[i][Owned] = strval(savingstring);
cache_get_field_content(0, "Locked", savingstring), hInfo[i][Locked] = strval(savingstring);
cache_get_field_content(0, "Price", savingstring), hInfo[i][Price] = strval(savingstring);
cache_get_field_content(0, "OX", savingstring), hInfo[i][OX] = strval(savingstring);
cache_get_field_content(0, "OY", savingstring), hInfo[i][OY] = strval(savingstring);
cache_get_field_content(0, "OZ", savingstring), hInfo[i][OZ] = strval(savingstring);
cache_get_field_content(0, "World", savingstring), hInfo[i][World] = strval(savingstring);
cache_get_field_content(0, "OnSale", savingstring), hInfo[i][OnSale] = strval(savingstring);
cache_get_field_content(0, "InteriorID", savingstring), hInfo[i][InteriorID] = strval(savingstring);
new lString[500];
if(hInfo[i][OnSale] == 0 )
{
switch(hInfo[i][Owned])
{
case 0:
{
format(lString, sizeof(lString), "House Owned: No\nHouse Owner: No one\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][EnterPickup] = CreateDynamicPickup(1273, 23, hInfo[i][OX],hInfo[i][OY], hInfo[i][OZ], -1, -1, -1, 36.0);
}
}
CreatedHouses++;
}
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++;
}
}
printf("[House System] %i houses were created...", CreatedHouses);
return 1;
}
I have tried so many different ways to fix this, but I just can't seem to do it. Thanks
Re: Houses not loading (MySQL) -
Misiur - 07.03.2015
pawn Код:
native cache_get_field_content(row, const field_name[], destination[], connectionHandle = 1, max_len = sizeof(destination));
First argument is row index, so change your
pawn Код:
cache_get_field_content(0,(...)
to
pawn Код:
cache_get_field_content(i,
(also start your loop from 0, not 1)
Re: Houses not loading (MySQL) -
FOTIS6 - 07.03.2015
Код:
hInfo[i][HID] = cache_get_field_content_int(i, "ID");
cache_get_field_content(i, "Owner", hInfo[i][Owner], mysql);
hInfo[i][Owned] = cache_get_field_content_int(i, "Owned");
hInfo[i][Locked] = cache_get_field_content_int(i, "Locked");
hInfo[i][Price] = cache_get_field_content_int(i, "Price");
hInfo[i][OX] = cache_get_field_content_float(i, "OX");
hInfo[i][OY] = cache_get_field_content_float(i, "OY");
hInfo[i][OZ] = cache_get_field_content_float(i, "OZ");
hInfo[i][World] = cache_get_field_content_int(i, "World");
hInfo[i][OnSale] = cache_get_field_content_int(i, "OnSale");
hInfo[i][InteriorID] = cache_get_field_content_int(i, "InteriorID");
Use something like that instead of that think you made with strval, strval converts a string into an integer but not a float, which means that the position will always be 0 the way you made it. That one should work
Re: Houses not loading (MySQL) -
FunnyBear - 07.03.2015
Thanks both, it works. But I have a small problem, it doesn't load the name of the owner,
Код:
cache_get_field_content(i, "Owner", hInfo[i][Owner], mysql);
Re: Houses not loading (MySQL) -
Luca12 - 07.03.2015
pawn Код:
cache_get_field_content(i,"Owner",hInfo[i][Owner],mysql,128);// try this code it will work.
Re: Houses not loading (MySQL) -
Misiur - 07.03.2015
Yeah, it's a known quirk with enumerated tables, sizeof simply doesn't work

Use @Lukca12 code, or check out the size of your "Owner" key
Re: Houses not loading (MySQL) -
StarPeens - 08.03.2015
check here have good systems
Click