a simple question. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: a simple question. (
/showthread.php?tid=656753)
a simple question. -
Florin48 - 23.07.2018
which of these two functions is faster and better, or are they both the same?
1:
PHP код:
if(zGangZones[zoneid][zIsUsingBorders])
{
GangZoneHideForPlayer(playerid, zGangZones[zoneid][border][0]);
GangZoneHideForPlayer(playerid, zGangZones[zoneid][border][1]);
GangZoneHideForPlayer(playerid, zGangZones[zoneid][border][2]);
GangZoneHideForPlayer(playerid, zGangZones[zoneid][border][3]);
}
or
2:
PHP код:
if(zGangZones[zoneid][zIsUsingBorders])
{
for(new i = 0; i < 4; i++) {
GangZoneHideForPlayer(playerid, zGangZones[zoneid][border][i]);
}
}
Re: a simple question. -
coool - 23.07.2018
I don't know about speed but the second one is better because if in future you want add or delete gang zones, then you will only have to adjust the array.. and also change the "4" to "sizeof(zGangZones[zoneid][border])".
Re: a simple question. -
GTLS - 23.07.2018
It will be same. It only makes your code looks better nothing else. What loop does it execute those lines number of times instead of writing it that number of times separately.