04.04.2014, 13:46
I have been thinking about this alot lately and it does not seem a bad idea:
With the current SA:MP versions, using (Player)TextDrawSetString will take effect immediately, while the other textdraw settings require TextDrawShowForPlayer feature for their effect to get applied.
This means, when you want to update a textdraw's features (excluding text and color) you just need ONE textdraw, instead of one for each player, unlikely when you need to update text, because you will need one textdraw per player.
Here's an example (Assuming the textdraws being visible all the time):
Based on this example, I think it'd be better if TextDrawSetString requires TextDrawShowForPlayer too, so we can use just one textdraw, instead of one for each player.
With the current SA:MP versions, using (Player)TextDrawSetString will take effect immediately, while the other textdraw settings require TextDrawShowForPlayer feature for their effect to get applied.
This means, when you want to update a textdraw's features (excluding text and color) you just need ONE textdraw, instead of one for each player, unlikely when you need to update text, because you will need one textdraw per player.
Here's an example (Assuming the textdraws being visible all the time):
pawn Код:
new Text:TextDrawWithString;
new Text:TextDrawWithoutString;
public OnGameModeInit()
{
// Textdraw in which we won't use any text.
TextDrawWithoutString = TextDrawCreate(...);
TextDrawBox(...);
TextDrawBoxColor(...);
// Textdraw in which we need text.
TextDrawWithString = TextDrawCreate(...);
TextDrawBox(...);
TextDrawBoxColor(...);
return 1;
}
public OnSomeFunction(playerid)
{
TextDrawUseBox(TextDrawWithoutString, true);
TextDrawShowForPlayer(playerid);
// Here the textdraw will update for one player (in this case for playerid), even
// though it is shown for all players.
TextDrawSetString(TextDrawWithString, COLOR_WHATEVER, "String to be updated for one player.");
TextDrawShowForPlayer(playerid);
//As we see, the string will be updated for all players online.
return 1;
}