10.02.2014, 21:34
pawn Код:
//This is the call under OnGameModeInit
LoadBus()
{
new query[500];
for(new i = 1; i < MAX_BUS; i++)
{
format(query, sizeof(query), "SELECT * FROM `Business` WHERE BusID='%d'", i);
mysql_function_query(dbHandle, query, true, "BusLoad", "i", i);
}
return 1;
}
pawn Код:
public BusLoad(i)
{
new rows,
fields,
temp[100],
busname[128],
owner[32];
cache_get_data(rows, fields);
if(rows)
{
cache_get_row(0, 0, busname);
format(BusInfo[i][BusName], 128, "%s", busname);
cache_get_row(0, 1, temp), BusInfo[i][BusIncome] = strval(temp);
cache_get_row(0, 2, temp), BusInfo[i][Price] = strval(temp);
BusInfo[i][CPX] = cache_get_row_float(0, 3);
BusInfo[i][CPY] = cache_get_row_float(0, 4);
BusInfo[i][CPZ] = cache_get_row_float(0, 5);
cache_get_row(0, 6, temp), BusInfo[i][BusID] = strval(temp);
cache_get_row(0, 7, owner);
format(BusInfo[i][Owner], 32, "%s", owner);
BusInfo[i][iX] = cache_get_row_float(0, 8);
BusInfo[i][iY] = cache_get_row_float(0, 9);
BusInfo[i][iZ] = cache_get_row_float(0, 10);
cache_get_row(0, 11, temp), BusInfo[i][Owned] = strval(temp);
cache_get_row(0, 12, temp), BusInfo[i][cIDOwner] = strval(temp);
cache_get_row(0, 13, temp), BusInfo[i][Interior] = strval(temp);
cache_get_row(0, 14, temp), BusInfo[i][VirtualWorld] = strval(temp);
new labeltext[220];
if(BusInfo[i][Owned] == 0)
{
if(BusInfo[i][iX] > 0 && BusInfo[i][iZ] > 0 && BusInfo[i][iZ] > 0)
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
else if(BusInfo[i][iX] == 0 && BusInfo[i][iZ] == 0 && BusInfo[i][iZ] == 0)
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Price: {33FF00}${FFFFFF}%d\n{00FF33}For Sale!", BusInfo[i][BusName], BusInfo[i][Price]);
}
}
else
{
if(BusInfo[i][iX] > 0 && BusInfo[i][iZ] > 0 && BusInfo[i][iZ] > 0)
{
format(labeltext, sizeof(labeltext), "{00FF33}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
else if(BusInfo[i][iX] == 0 && BusInfo[i][iZ] == 0 && BusInfo[i][iZ] == 0)
{
format(labeltext, sizeof(labeltext), "{FF0000}%s\n{FFFFFF}Owned By: %s", BusInfo[i][BusName], BusInfo[i][Owner]);
}
}
BusLabel[i] = CreateDynamic3DTextLabel(labeltext, COLOR_SNOW, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
BizzEnter[i] = CreateDynamicPickup(1272, 23, BusInfo[i][CPX], BusInfo[i][CPY], BusInfo[i][CPZ], -1, -1, -1, 100.0);
BusCount ++;
}
return 1;
}