Which way would be faster [car-player or player-car]
#1

Alright, so I need to optimize one script part as it gives huge CPU usage.

this
pawn Код:
for(new i = 0; i < MAX_VEHICLES; i++) //1700
{
GetVehicleHealth(i,VHP);
foreach(Player,playerid)
{
//Script
}
}
or
pawn Код:
foreach(Player,playerid)
{
if(GetPlayerState(playerid) == 2)
{
new i = GetPlayerVehicleID(playerid);
GetVehicleHealth(i,VHP);
//Script
}
}
In basic its scipt which will auto set car HP to 251 if its under 250 ( starts burning )
Player is needed as its also check if player HP isnt under 15, if so he cant drive the car


Thank you in advice
Reply
#2

The second one because it checks all the players state and see if it's on vehicle or not and if so get the id. The first one will be slower as a result
Reply
#3

Oh alright, thanks, just tested 2nd variant, CPU from 70% went to 15% :$ :$ :$
small failzor
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)