[Include] MAX_PLAYERS Loops
#1

deleted
Reply
#2

Uhmmm .. there is already foreach ( or y_iterate ) for this
pawn Код:
foreach (new i : Player)
Link to foreach : https://sampforum.blast.hk/showthread.php?tid=92679
And, you can use y_hook for hooking callbacks too!

Anyways, it's a nice work as it's your second release on the forums
Reply
#3

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Uhmmm .. there is already foreach ( or y_iterate ) for this
This Include from ****** works completely different!

mfg.
Reply
#4

Nice work, but as said foreach is much better. If only ID 499 is connected, this is still going to loop through the first 499 IDs which aren't connected
Reply
#5

The classic example of having variables, loops etc.. faster just #undef MAX_PLAYERS and #define MAX_PLAYERS (SERVER_SLOT)...on this case you re-define MAX_PLAYERS and should work faster. Another example for loops can be
pawn Код:
for(new i=0; i< GetMaxPlayers(); i++)
a faster loop.

As above users said y_iterate is much faster.
Reply
#6

rather do it like this
pawn Код:
for(new i, j = GetMaxPlayers(); i < j; i++)
And yeah, cosider taking a look at y_iterate, it is very efficient, not just for player looping (there are examples for different usages)
Reply
#7

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
pawn Код:
for(new i=0; i< GetMaxPlayers(); i++)
a faster loop.
This isnt faster, because you call a Funktion, to use a Makro it's much faster!

I know foreach, but the system how it works is totally different and so its doesnt matter!
Reply
#8

Useless dude.
Reply
#9

Calling a function doesn't mean it is slow.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)