What's more efficient?
#1

I was wondering what would be more efficient and cause less lag, even the slightest bit.

I have a textdraw that uses an array, like TextDrawShowForPlayer(playerid, textname[playerid]);.

I was wondering whether to use it on OnPlayerConnect or OnGameModeInit, When I put it on OnGameModeInit, I need to create a loop, for OnPlayerConnect I don't.

So what would be more efficient?

Thanks in advance.
Reply
#2

OnPlayerConnect will be good in my opinion.
All my textdraws are OnPlayerConnect
Reply
#3

Quote:
Originally Posted by JoeDaDude
OnPlayerConnect will be good in my opinion.
All my textdraws are OnPlayerConnect
Well, that would make the server have to load the textdraw on every connect, OnGameModeInit loads it once with a loop, but it's considered about 200 textdraw's or whatever MAX_PLAYERS if defined as.
Reply
#4

Definitely OnPlayerConnect() is the way to go, because there is no guarantee that any players are connected at all in OnGameModeInit(). It takes time to connect after a gamemode starts, so your players may not be connected yet.

And it is better to spread out the load of the server over time, rather than to call everything at once, because PAWN is single-threaded. So, calling your function 200 times in a loop will stop anything else from happening until the loop finishes. Calling your function once every time a person connects will be much more efficient for you.

~Cueball~
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)