22.05.2012, 15:26
Try this:
pawn Код:
stock LoadBusinesses()
{
new
Str[128],
string[512],
bID,
bName[128],
bOwner[24],
Float:ExtX,
Float:ExtY,
Float:ExtZ,
Float:IntX,
Float:IntY,
Float:IntZ,
Price,
Enterable,
IntID;
mysql_query("SELECT * FROM `Businesses`");
mysql_store_result();
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Str))
{
sscanf(Str, "p<|>is[128]s[24]ffffffiii", bID, bName, bOwner, ExtX, ExtY, ExtZ, IntX, IntY, IntZ, IntID, Price, Enterable);
BusinessPickup[bID] = CreatePickup(1272, 1, ExtX, ExtY, ExtZ, 0);
if(Enterable == 0)
{
format(string, sizeof(string), "{FF0000}Business %d\nPrice $%d\nName: %s\nOwner: %s", bID, Price, bName, bOwner);
}
else
{
format(string, sizeof(string), "{33FF33}Business %d\nPrice $%d\nName: %s\nOwner: %s", bID, Price, bName, bOwner);
}
Create3DTextLabel(string, BLUE, ExtX, ExtY, ExtZ, 5.0, 0, 1);
print(string);
bTotal++;
}
}
for(new i = 0; i < MAX_BUSINESS; i++)
{
Business[i][BusinessExteriorX] = ExtX;
Business[i][BusinessExteriorY] = ExtY;
Business[i][BusinessExteriorZ] = ExtZ;
Business[i][BusinessInteriorX] = IntX;
Business[i][BusinessInteriorY] = IntY;
Business[i][BusinessInteriorZ] = IntZ;
Business[i][BusinessInteriorID] = IntID;
Business[i][BusinessPrice] = Price;
Business[i][BusinessEnterable] = Enterable;
format(Business[i][BusinessName], 128, "%s", bName);
format(Business[i][BusinessOwner], 24, "%s", bOwner);
}
mysql_free_result();
printf("%i businesses loaded from the MySQL Database.", bTotal);
}