12.07.2014, 17:25
Read the tutorial: https://sampforum.blast.hk/showthread.php?tid=337810
Read the wiki (R33+): https://sampwiki.blast.hk/wiki/MySQL/R33
Update to R39-2 and use:
@electrux: "Houses_Table" is defined and the usage of the sscanf is fine even though it's not needed.
Read the wiki (R33+): https://sampwiki.blast.hk/wiki/MySQL/R33
Update to R39-2 and use:
pawn Код:
LoadHouses()
{
mysql_tquery(SQL, "SELECT * FROM "Houses_Table"", "CB_LoadHouses", "");
}
forward CB_LoadHouses();
public CB_LoadHouses()
{
for (new i = 0, rows = cache_num_rows(); i != rows; ++i)
{
if (i >= sizeof (HouseInfo)) break;
// assign the values to the variables.. and use "i" as rowid.
// cache_get_row(_int/_float) or cache_get_field_content(_int/_float)
new lString[100];
switch(HouseInfo[i][Owned])
{
case 0:
{
format(lString, sizeof(lString), "House Owned: No\nHouse Owner: None\nHouse Price: $%i", HouseInfo[i][Price]);
HouseInfo[i][Label] = CreateDynamic3DTextLabel(lString, -1, HouseInfo[i][OX], HouseInfo[i][OY], HouseInfo[i][OZ]+0.5, 20.0);
HouseInfo[i][Icon] = CreateDynamicMapIcon(HouseInfo[i][OX], HouseInfo[i][OY], HouseInfo[i][OZ], 31, -1);
HouseInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, HouseInfo[i][OX], HouseInfo[i][OY], HouseInfo[i][OZ], -1, -1, -1, 20.0);
HouseInfo[i][ExitPickup] = CreateDynamicPickup(1273, 23, HouseInfo[i][IX], HouseInfo[i][IY], HouseInfo[i][IZ], -1, -1, -1, 20.0);
}
case 1:
{
format(lString, sizeof(lString),"House Owned: Yes\nHouse Owner: %s\nHouse Price: $%i\nHouse Locked: %s", HouseInfo[i][Owner], HouseInfo[i][Price], (HouseInfo[i][Locked] == 1) ? ("Yes") : ("No"));
HouseInfo[i][Label] = CreateDynamic3DTextLabel(lString, -1, HouseInfo[i][OX], HouseInfo[i][OY], HouseInfo[i][OZ]+0.5, 20.0);
HouseInfo[i][Icon] = CreateDynamicMapIcon(HouseInfo[i][OX], HouseInfo[i][OY], HouseInfo[i][OZ], 32, -1);
HouseInfo[i][EnterPickup] = CreateDynamicPickup(1273, 23, HouseInfo[i][OX],HouseInfo[i][OY], HouseInfo[i][OZ], -1, -1, -1, 20.0);
HouseInfo[i][ExitPickup] = CreateDynamicPickup(1273, 23, HouseInfo[i][IX], HouseInfo[i][IY], HouseInfo[i][IZ], -1, -1, -1, 20.0);
}
}
CreatedHouses++;
}
printf("[House System] %i houses were retrieved..", CreatedHouses);
}