14.09.2010, 20:14
I was just thinking, would a value checking be faster than
like
I did a quick test with code
Foreach was 104 msec, and mine was 41 msec.
pawn Code:
IsPlayerConnected(playerid)
pawn Code:
public OnPlayerConnect(playerid) connected[playerid]=true;
public OnPlayerDisconnect(playerid) connected[playerid]=false;
for(new i; i< MAX_PLAYERS;i++)
{
if(connected[playerid])
{
// do sth here.
}
}
pawn Code:
new time = GetTickCount();
for (new i = 0; i < 10000; i++)
{
foreach(Player,I)
{
item1[I][i]=100;
}
}
printf("Time #1: %d", GetTickCount() - time);
time = GetTickCount();
for (new i = 0; i < 10000; i++)
{
for(new I=0;I<100;I++) { if(connected[I])
{
item3[I][i]=300;
} }
}
printf("Time #3: %d", GetTickCount() - time);