07.10.2012, 13:59
Помогите пожалуйста оптимизировать коллбэк!
Больше всего напрягает цикл обновлением у машин 3д текста
PHP код:
public CheckCar() {
new string[100], set;
for(new i; i < GetMaxPlayers(); i++) {
if(!IsPlayerConnected(i)) continue;
if(PlayerInfo[i][pCashs] != GetPlayerMoney(i)) {
ResetPlayerMoney(i);
GivePlayerMoney(i, PlayerInfo[i][pCashs]);
}
if(PlayerEx[i][ChekEx] == PlayerEx[i][TickEx]) if(PlayerEx[i][pSpawnEx] == true) PlayerEx[i][AFKEx] = true;
PlayerEx[i][ChekEx] = PlayerEx[i][TickEx];
if(IDVEH[i] != -1 && IsPlayerInAnyVehicle(i) && !UseEnter[i] && IDVEH[i] != GetPlayerVehicleID(i)) Punish(i);
}
for(new x; x < sizeof(mehanik); x++) {
set = 0;
for(new i; i < GetMaxPlayers(); i++) {
if(!IsPlayerConnected(i)) continue;
if(GetPVarInt(i,"MexKo") > -1 && GetPlayerVehicleID(i) == mehanik[x] && GetPlayerVehicleID(i) == GetPVarInt(i,"arenda")) {
set++;
format(string, sizeof(string), "На работе: %s", SBizzInfo[GetPVarInt(i,"MexKo")][sbMessage]);
Update3DTextLabelText(Meh3d[x], 0x008080FF, string);
}
}
if(set == 0) Update3DTextLabelText(Meh3d[x], 0x008080FF, "Не работает!");
}
for(new j=0; j<MAX_VEHICLES; j++) {
if(zaved[j] == true) {
if(Fuell[j] >= 0) {
Fuell[j] -= 0.2;
for(new i= 0; i < GetMaxPlayers(); i++) {
if(!IsPlayerConnected(i)) continue;
if(j == caridhouse[i]) PlayerInfo[i][pFuelcar] = Fuell[j];
}
}
else {
if(GetVehicleModel(j) != 462 && GetVehicleModel(j) != 510 && GetVehicleModel(j) != 509 && GetVehicleModel(j) != 481) {
GetVehicleParamsEx(j,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(j,VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
zaved[j] = false;
}
}
}
}
return true;
}