10.04.2019, 21:32
So I'm trying to make a /time command which should show a textdraw displaying the current time. But instead I see a black box. What did I do wrong?
PHP код:
new Text:InfoText[MAX_PLAYERS], DisplayingText[MAX_PLAYERS], TextTiming[MAX_PLAYERS];
stock CreateInfoTextDraw(playerid)
{
InfoText[playerid] = TextDrawCreate(319.000000, 380.000000, "");
TextDrawAlignment(InfoText[playerid], 2);
TextDrawBackgroundColor(InfoText[playerid], 255);
TextDrawFont(InfoText[playerid], 1);
TextDrawLetterSize(InfoText[playerid], 0.320000, 1.500000);
TextDrawSetProportional(InfoText[playerid], 1);
TextDrawSetShadow(InfoText[playerid], 1);
}
stock DisplayInfoTextDraw(playerid, str[], duration)
{
if(DisplayingText[playerid])
{
KillTimer(TextTiming[playerid]);
}
TextDrawSetString(InfoText[playerid], str);
TextDrawShowForPlayer(playerid, InfoText[playerid]);
TextTiming[playerid] = SetTimerEx("HideInfoTextDraw", duration *1000, 0, "i", playerid);
DisplayingText[playerid] = 1;
return 1;
}
stock HideInfoTextDraw(playerid)
{
TextDrawHideForPlayer(playerid, InfoText[playerid]);
DisplayingText[playerid] = 0;
return 1;
}
stock MonthName(Month)
{
new MonthStr[15];
switch(Month)
{
case 1: MonthStr = "January";
case 2: MonthStr = "February";
case 3: MonthStr = "March";
case 4: MonthStr = "April";
case 5: MonthStr = "May";
case 6: MonthStr = "June";
case 7: MonthStr = "July";
case 8: MonthStr = "August";
case 9: MonthStr = "September";
case 10: MonthStr = "October";
case 11: MonthStr = "November";
case 12: MonthStr = "December";
}
return MonthStr;
}
CMD:time(playerid,params[])
{
new month, day, year, hour, minute, second, str[500];
getdate(year, month, day);
gettime(hour, minute, second);
if(Account[playerid][Prison] == 1)
{
format(str, sizeof(str), "~y~%02d %s, %d ~w~~n~%02d:%02d:%02d~n~Prison Sentence: %d minutes and %d seconds", day, MonthName(month), year, hour, minute, second, Account[playerid][PrisonTime] / 60, Account[playerid][PrisonTime] / 60 / 60);
}
else
{
format(str, sizeof(str), "~y~%02d %s, %d ~w~~n~%02d:%02d:%02d", day, MonthName(month), year, hour, minute, second);
}
DisplayInfoTextDraw(playerid, str, 8);
return 1;
}