17.02.2018, 20:44
I see that I have in my game mode at least 40 global textdraws, but I do not think that the way they are created is the most optimal.
For example, I have this from my registration system...
And this in OnGameModeInit
And here are the functions to load and hide the textdraws
Straight to the point, the question is whether it is better to create the registration and login textdraws for the MAX_PLAYERS when you start the server, or create these when the player connects. (Thinking about minimizing the slowness of the server), take into account that I have at least 40 textdraws created in the same way .. I have no problem compiling but I see that the server is somewhat slower since it implements these ..
For example, I have this from my registration system...
PHP Code:
new Text:BackgroundTextDraw[MAX_PLAYERS];
new Text:ServerNameTextDraw[MAX_PLAYERS];
new Text:LoginTextDraw[MAX_PLAYERS];
new Text:RegisterTextDraw[MAX_PLAYERS];
new Text:CreditsTextDraw[MAX_PLAYERS];
new Text:RulesTextDraw[MAX_PLAYERS];
new Text:TeamTextDraw[MAX_PLAYERS];
PHP Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
BackgroundTextDraw[i] = TextDrawCreate(2.000000, 208.000000, "usebox");
//(INFO)
ServerNameTextDraw[i] = TextDrawCreate(315.000000, 97.562500, "ServerNameRP");
//(INFO)
LoginTextDraw[i] = TextDrawCreate(308.000000, 120, "Login");
//(INFO)
RegisterTextDraw[i] = TextDrawCreate(308.000000, 121.625000, "Register");
//(INFO)
CreditsTextDraw[i] = TextDrawCreate(307.500000, 140, "Credits");
//(INFO)
RulesTextDraw[i] = TextDrawCreate(309.000000, 160, "Rules");
//(INFO)
TeamTextDraw[i] = TextDrawCreate(309.000000, 180, "Team");
//(INFO)
}
PHP Code:
ShowLoginTextDraws(playerid)
{
TextDrawShowForPlayer(playerid, BackgroundTextDraw[playerid]);
TextDrawShowForPlayer(playerid, ServerNameTextDraw[playerid]);
TextDrawShowForPlayer(playerid, CreditsTextDraw[playerid]);
TextDrawShowForPlayer(playerid, RulesTextDraw[playerid]);
TextDrawShowForPlayer(playerid, TeamTextDraw[playerid]);
SelectTextDraw(playerid, -1);
return true;
}
HideLoginTextDraws(playerid)
{
TextDrawHideForPlayer(playerid, BackgroundTextDraw[playerid]);
TextDrawHideForPlayer(playerid, ServerNameTextDraw[playerid]);
TextDrawHideForPlayer(playerid, CreditsTextDraw[playerid]);
TextDrawHideForPlayer(playerid, RulesTextDraw[playerid]);
TextDrawHideForPlayer(playerid, TeamTextDraw[playerid]);
TextDrawHideForPlayer(playerid, LoginTextDraw[playerid]);
TextDrawHideForPlayer(playerid, RegisterTextDraw[playerid]);
CancelSelectTextDraw(playerid);
return true;
}