24.03.2014, 06:56
Всем привет, во время использования данной функции
Игровой сервер зависает секунд на 3-7-10, как можно это поправить? Оптимизировать запросы или хз что там, помогите пожалуйста)
PHP код:
stock SellHouse()
{
new bank, notice[8], text[3],playerid;
for(new i = 1; i <= TOTALHOUSE; i++)
{
HouseInfo[i][hRobhouse] = false;
if (HouseInfo[i][hOwned] == 0) continue;
if (HouseInfo[i][hTakings] < HouseInfo[i][hPaycash])
{
playerid = INVALID_PLAYER_ID;
sscanf(HouseInfo[i][hOwner], "u", playerid);
if (IsPlayerConnected(playerid))
{
PlayerInfo[playerid][pBank] += HouseInfo[i][hValue]+HouseInfo[i][hTakings]-HouseInfo[i][hPaycash]*2;
PlayerInfo[playerid][pIDHouse] = 0;
SetPVarInt(playerid, "GetHome", 1);
}
else
{
format(query,sizeof(query), "SELECT Bank, Notice FROM "TABLE_ACCOUNT" WHERE Name = '%s'", HouseInfo[i][hOwner]);
mysql_query(query);
mysql_store_result();
if (mysql_fetch_row_format(query))
{
sscanf(query, "p<|>is[8]", bank, notice);
}
mysql_free_result();
sscanf(notice, "p<,>a<i>[3]", text);
text[0] = 1;
format(notice, sizeof(notice),"%d,%d,%d", text[0], text[1], text[2]);
bank += HouseInfo[i][hValue];
SetPlayerInt(HouseInfo[i][hOwner],"Bank",bank);
SetPlayerStr(HouseInfo[i][hOwner],"Notice",notice);
}
HouseInfo[i][hOwned] = 0;
HouseInfo[i][hHealme] = 0;
HouseInfo[i][hTakings] = 0;
strmid(HouseInfo[i][hOwner], "The State", 0, strlen("The State"), 255);
SetHouseStr(i,"Owner",HouseInfo[i][hOwner]);
SetHouseInt(i,"Owned",HouseInfo[i][hOwned]);
SetHouseInt(i,"Takings",HouseInfo[i][hTakings]);
SetHouseInt(i,"Healme",HouseInfo[i][hHealme]);
UpdateHouseInfo(i);
}
else
{
HouseInfo[i][hTakings] -= HouseInfo[i][hPaycash];
SetHouseInt(i,"Takings",HouseInfo[i][hTakings]);
}
}
return 1;
}