Created
December 25, 2022 05:44
-
-
Save ohmypxl/747d29648f1088598ecfff2a90917f5b to your computer and use it in GitHub Desktop.
Simple clock textdraw with overload macros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Overload macros for UpdateTextDrawTime | |
#define UpdateTextDrawTime(%1) (_:UTDT0:UTDT1:UpdateTdOvrld(%1)) | |
#define UTDT0:UTDT1:UpdateTdOvrld(%1,%8PlayerText%9:%2) UpdateTextDrawTime__(%2,%1) | |
#define UTDT1:UpdateTdOvrld(%8Text%9:%1) UpdateTextDrawTime__(%1) | |
UpdateTextDrawTime__({PlayerText, Text}:textdraw, extraid = INVALID_PLAYER_ID, tag = tagof(textdraw)) | |
{ | |
new hour, minute, second; | |
gettime(hour, minute, second); | |
new string:timeFmt[64]; | |
format(timeFmt, sizeof(timeFmt), "%02d:%02d:%02d", hour, minute, second); | |
if (tag == tagof(PlayerText:)) | |
{ | |
PlayerTextDrawSetString(extraid, textdraw, timeFmt); | |
} | |
else if (tag == tagof(Text:)) | |
{ | |
// Need to retag because of stupid warning | |
TextDrawSetString(Text:_:textdraw, timeFmt); | |
} | |
else | |
{ | |
return 0; | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Example
TextDraw usage
PlayerTextDraw usage