#define ShowOpeningTD(%1) TextDrawShowForPlayer(%1, OP1); TextDrawShowForPlayer(%1, OP2); TextDrawShowForPlayer(%1, OP3); TextDrawShowForPlayer(%1, OP4); TextDrawShowForPlayer(%1, OP5)
OP5 = TextDrawCreate(312.666687, 29.037025, "~y~Welcome to~n~~b~MILLITARY ~w~VS ~r~REBELS~n~~w~%s");
TextDrawLetterSize(OP5, 0.449999, 1.600000);
TextDrawAlignment(OP5, 2);
TextDrawColor(OP5, 0);
TextDrawSetShadow(OP5, 0);
TextDrawSetOutline(OP5, 0);
TextDrawBackgroundColor(OP5, 51);
TextDrawFont(OP5, 2);
TextDrawSetProportional(OP5, 1);
public OnPlayerConnect(playerid)
{
new string[128];
format(string, sizeof(string), "~y~Welcome to~n~~b~MILLITARY ~w~VS ~r~REBELS~n~~w~%s", RPN(playerid));
TextDrawSetString(OP5, string);
ShowOpeningTD(playerid);
return 1;
}
new string[128]; format(string, sizeof(string), "~y~Welcome to~n~~b~MILLITARY ~w~VS ~r~REBELS~n~~w~%s", RPN(playerid)); TextDrawSetString(OP5, string); TextDrawShowForPlayer(playerid, OP5);
#define ShowOpeningTD(%0) TextDrawShowForPlayer(%0, OP1)
#define ShowOpeningTD2(%0) TextDrawShowForPlayer(%0, OP2)
#define ShowOpeningTD3(%0) TextDrawShowForPlayer(%0, OP3)
#define ShowOpeningTD4(%0) TextDrawShowForPlayer(%0, OP4)
#define ShowOpeningTD5(%0) TextDrawShowForPlayer(%0, OP5)
ShowOpeningTD(playerid)
{
TextDrawShowForPlayer(playerid, OP1);
TextDrawShowForPlayer(playerid, OP2);
TextDrawShowForPlayer(playerid, OP3);
TextDrawShowForPlayer(playerid, OP4);
TextDrawShowForPlayer(playerid, OP5);
}
Start using functions instead of cramming everything into an unreadable macro. Macros are meant for small things, not entire function bodies.
PHP код:
|
Start using functions instead of cramming everything into an unreadable macro. Macros are meant for small things, not entire function bodies.
PHP код:
|
TextDrawShowForPlayer(playerid, OP1);
TextDrawShowForPlayer(playerid, OP2);
TextDrawShowForPlayer(playerid, OP3);
TextDrawShowForPlayer(playerid, OP4);
TextDrawShowForPlayer(playerid, OP5);
I have read some code optimization thread claiming regular vars are way better and faster than arrays, that's why
|
While this is true, it decreases readability and most importantly maintainability. I would always use x, y and z over pos[3], but once I need 4 or more similar variables I will generally use an array.
|