Kosty66
Специалист
Clock Beta 0.1.
Общее.В этом уроке мы научимся делать красивые асы на TextDraw'e, в которых будет указано:
- Месяц
- Год
- Час:минута:секунда
- Число
Поехали.
1. Добавляем new к new:
PHP:
new Text:Box1Blue[MAX_PLAYERS];
new Text:DateTD[MAX_PLAYERS];
new Text:HourTD[MAX_PLAYERS];
new Text:YearTD[MAX_PLAYERS];
new Text:BoxYear[MAX_PLAYERS];
new Text:DayTD[MAX_PLAYERS];
new Text:BoxDay[MAX_PLAYERS];
new Text:InfoHour[MAX_PLAYERS];
new Text:InfoSeconds[MAX_PLAYERS];
new Text:InfoMinutes[MAX_PLAYERS];
PHP:
forward LoadTextdraws(playerid);
forward FuncionClock(playerid);
PHP:
LoadTextdraws(playerid);
ShowTextdrawsClock(playerid);
PHP:
HideTextdrawsClock(playerid);
PHP:
public LoadTextdraws(playerid)
{
Box1Blue[playerid] = TextDrawCreate(630.000000, 200.000000, " ");
TextDrawBackgroundColor(Box1Blue[playerid], 255);
TextDrawFont(Box1Blue[playerid], 1);
TextDrawLetterSize(Box1Blue[playerid], 0.500000, 1.000000);
TextDrawColor(Box1Blue[playerid], -1);
TextDrawSetOutline(Box1Blue[playerid], 0);
TextDrawSetProportional(Box1Blue[playerid], 0);
TextDrawSetShadow(Box1Blue[playerid], 1);
TextDrawUseBox(Box1Blue[playerid], 1);
TextDrawBoxColor(Box1Blue[playerid], 134777599);
TextDrawTextSize(Box1Blue[playerid], 460.000000, 30.000000);
TextDrawSetSelectable(Box1Blue[playerid], 0);
DateTD[playerid] = TextDrawCreate(466.000000, 237.000000, "15 November");
TextDrawBackgroundColor(DateTD[playerid], 255);
TextDrawFont(DateTD[playerid], 2);
TextDrawLetterSize(DateTD[playerid], 0.340000, 1.000000);
TextDrawColor(DateTD[playerid], -1);
TextDrawSetOutline(DateTD[playerid], 0);
TextDrawSetProportional(DateTD[playerid], 1);
TextDrawSetShadow(DateTD[playerid], 1);
TextDrawSetSelectable(DateTD[playerid], 0);
HourTD[playerid] = TextDrawCreate(470.000000, 206.000000, "04:12:20");
TextDrawBackgroundColor(HourTD[playerid], 255);
TextDrawFont(HourTD[playerid], 3);
TextDrawLetterSize(HourTD[playerid], 0.999999, 3.099999);
TextDrawColor(HourTD[playerid], -1);
TextDrawSetOutline(HourTD[playerid], 0);
TextDrawSetProportional(HourTD[playerid], 1);
TextDrawSetShadow(HourTD[playerid], 1);
TextDrawSetSelectable(HourTD[playerid], 0);
YearTD[playerid] = TextDrawCreate(582.000000, 185.000000, "2012");
TextDrawBackgroundColor(YearTD[playerid], 255);
TextDrawFont(YearTD[playerid], 2);
TextDrawLetterSize(YearTD[playerid], 0.430000, 1.000000);
TextDrawColor(YearTD[playerid], -1);
TextDrawSetOutline(YearTD[playerid], 0);
TextDrawSetProportional(YearTD[playerid], 1);
TextDrawSetShadow(YearTD[playerid], 1);
TextDrawSetSelectable(YearTD[playerid], 0);
BoxYear[playerid] = TextDrawCreate(630.000000, 185.000000, " ");
TextDrawBackgroundColor(BoxYear[playerid], 255);
TextDrawFont(BoxYear[playerid], 1);
TextDrawLetterSize(BoxYear[playerid], 0.500000, 1.000000);
TextDrawColor(BoxYear[playerid], -1);
TextDrawSetOutline(BoxYear[playerid], 0);
TextDrawSetProportional(BoxYear[playerid], 1);
TextDrawSetShadow(BoxYear[playerid], 1);
TextDrawUseBox(BoxYear[playerid], 1);
TextDrawBoxColor(BoxYear[playerid], 143263999);
TextDrawTextSize(BoxYear[playerid], 576.000000, 90.000000);
TextDrawSetSelectable(BoxYear[playerid], 0);
DayTD[playerid] = TextDrawCreate(466.000000, 182.000000, "Saturday");
TextDrawBackgroundColor(DayTD[playerid], 255);
TextDrawFont(DayTD[playerid], 2);
TextDrawLetterSize(DayTD[playerid], 0.470000, 1.500000);
TextDrawColor(DayTD[playerid], -1);
TextDrawSetOutline(DayTD[playerid], 0);
TextDrawSetProportional(DayTD[playerid], 1);
TextDrawSetShadow(DayTD[playerid], 1);
TextDrawSetSelectable(DayTD[playerid], 0);
BoxDay[playerid] = TextDrawCreate(582.000000, 185.000000, " ");
TextDrawBackgroundColor(BoxDay[playerid], 255);
TextDrawFont(BoxDay[playerid], 1);
TextDrawLetterSize(BoxDay[playerid], 0.500000, 1.000000);
TextDrawColor(BoxDay[playerid], -1);
TextDrawSetOutline(BoxDay[playerid], 0);
TextDrawSetProportional(BoxDay[playerid], 1);
TextDrawSetShadow(BoxDay[playerid], 1);
TextDrawUseBox(BoxDay[playerid], 1);
TextDrawBoxColor(BoxDay[playerid], -2037774081);
TextDrawTextSize(BoxDay[playerid], 460.000000, 20.000000);
TextDrawSetSelectable(BoxDay[playerid], 0);
InfoHour[playerid] = TextDrawCreate(476.000000, 199.000000, "Time");
TextDrawBackgroundColor(InfoHour[playerid], 255);
TextDrawFont(InfoHour[playerid], 2);
TextDrawLetterSize(InfoHour[playerid], 0.220000, 1.000000);
TextDrawColor(InfoHour[playerid], -1);
TextDrawSetOutline(InfoHour[playerid], 0);
TextDrawSetProportional(InfoHour[playerid], 1);
TextDrawSetShadow(InfoHour[playerid], 1);
TextDrawSetSelectable(InfoHour[playerid], 0);
InfoMinutes[playerid] = TextDrawCreate(522.000000, 199.000000, "Minute");
TextDrawBackgroundColor(InfoMinutes[playerid], 255);
TextDrawFont(InfoMinutes[playerid], 2);
TextDrawLetterSize(InfoMinutes[playerid], 0.220000, 1.000000);
TextDrawColor(InfoMinutes[playerid], -1);
TextDrawSetOutline(InfoMinutes[playerid], 0);
TextDrawSetProportional(InfoMinutes[playerid], 1);
TextDrawSetShadow(InfoMinutes[playerid], 1);
TextDrawSetSelectable(InfoMinutes[playerid], 0);
InfoSeconds[playerid] = TextDrawCreate(574.000000, 199.000000, "Seconds");
TextDrawBackgroundColor(InfoSeconds[playerid], 255);
TextDrawFont(InfoSeconds[playerid], 2);
TextDrawLetterSize(InfoSeconds[playerid], 0.220000, 1.000000);
TextDrawColor(InfoSeconds[playerid], -1);
TextDrawSetOutline(InfoSeconds[playerid], 0);
TextDrawSetProportional(InfoSeconds[playerid], 1);
TextDrawSetShadow(InfoSeconds[playerid], 1);
TextDrawSetSelectable(InfoSeconds[playerid], 0);
return 1;
}
PHP:
public FuncionClock(playerid)
{
new string[256], string2[256], string3[256], year, month, day, seconds, hour, minutes, daynum;
gettime(hour, minutes, seconds);
new textmonth[126], textday[20];
getdate(year, month, day);
if(month == 01) { textmonth = "January"; }
if(month == 02) { textmonth = "February"; }
if(month == 03) { textmonth = "March"; }
if(month == 04) { textmonth = "April"; }
if(month == 05) { textmonth = "May"; }
if(month == 06) { textmonth = "June"; }
if(month == 07) { textmonth = "July"; }
if(month == 08) { textmonth = "August"; }
if(month == 09) { textmonth = "September"; }
if(month == 10) { textmonth = "October"; }
if(month == 11) { textmonth = "November"; }
if(month == 12) { textmonth = "December"; }
getdate(year, month, daynum);
if(daynum == 1)
{
textday = "1";
}
else if(daynum == 2)
{
textday = "2";
}
else if(daynum == 3)
{
textday = "3";
}
else if(daynum == 4)
{
textday = "4";
}
else if(daynum == 5)
{
textday = "5";
}
else if(daynum == 6)
{
textday = "6";
}
else if(daynum == 7)
{
textmonth = "7";
}
else if(daynum == 8)
{
textmonth = "8";
}
else if(daynum == 9)
{
textmonth = "9";
}
else if(daynum == 10)
{
textmonth = "10";
}
else if(daynum == 11)
{
textmonth = "11";
}
else if(daynum == 12)
{
textday = "12";
}
else if(daynum == 13)
{
textday = "13";
}
else if(daynum == 14)
{
textday = "14";
}
else if(daynum == 15)
{
textday = "15";
}
else if(daynum == 16)
{
textday = "16";
}
else if(daynum == 17)
{
textday = "17";
}
else if(daynum == 18)
{
textday = "18";
}
else if(daynum == 19)
{
textday = "19";
}
else if(daynum == 20)
{
textday = "20";
}
else if(daynum == 21)
{
textday = "21";
}
else if(daynum == 22)
{
textday = "22";
}
else if(daynum == 23)
{
textday = "23";
}
else if(daynum == 24)
{
textday = "24";
}
else if(daynum == 25)
{
textday = "25";
}
else if(daynum == 26)
{
textday = "26";
}
else if(daynum == 27)
{
textday = "27";
}
else if(daynum == 28)
{
textday = "28";
}
else if(daynum == 29)
{
textday = "29";
}
else if(daynum == 30)
{
textday = "30";
}
else if(daynum == 31)
{
textday = "31";
}
new daylet;
daylet = GetDayLet(year, month, day);
if(daylet == 1){ TextDrawSetString(DayTD[playerid],"Thursday"); }
if(daylet == 2){ TextDrawSetString(DayTD[playerid],"Friday"); }
if(daylet == 3){ TextDrawSetString(DayTD[playerid],"Saturday"); }
if(daylet == 4){ TextDrawSetString(DayTD[playerid],"Sunday"); }
if(daylet == 5){ TextDrawSetString(DayTD[playerid],"Monday"); }
if(daylet == 6){ TextDrawSetString(DayTD[playerid],"Tuesday"); }
if(daylet == 7){ TextDrawSetString(DayTD[playerid],"Wednesday"); }
format(string, sizeof(string), "%d %s", daynum, textmonth);
TextDrawSetString(DateTD[playerid], string);
format(string2, sizeof(string2), "%d:%d:%d", hour, minutes, seconds);
TextDrawSetString(HourTD[playerid], string2);
format(string3, sizeof(string2), "%d", year);
TextDrawSetString(YearTD[playerid], string3);
return 1;
}
PHP:
stock ShowTextdrawsClock(playerid)
{
TextDrawShowForPlayer(playerid, Box1Blue[playerid]);
TextDrawShowForPlayer(playerid, DateTD[playerid]);
TextDrawShowForPlayer(playerid, HourTD[playerid]);
TextDrawShowForPlayer(playerid, YearTD[playerid]);
TextDrawShowForPlayer(playerid, BoxYear[playerid]);
TextDrawShowForPlayer(playerid, DayTD[playerid]);
TextDrawShowForPlayer(playerid, BoxDay[playerid]);
TextDrawShowForPlayer(playerid, InfoHour[playerid]);
TextDrawShowForPlayer(playerid, InfoSeconds[playerid]);
TextDrawShowForPlayer(playerid, InfoMinutes[playerid]);
return 1;
}
PHP:
stock HideTextdrawsClock(playerid)
{
TextDrawHideForPlayer(playerid, Box1Blue[playerid]);
TextDrawHideForPlayer(playerid, DateTD[playerid]);
TextDrawHideForPlayer(playerid, HourTD[playerid]);
TextDrawHideForPlayer(playerid, YearTD[playerid]);
TextDrawHideForPlayer(playerid, DayTD[playerid]);
TextDrawHideForPlayer(playerid, BoxDay[playerid]);
TextDrawHideForPlayer(playerid, InfoHour[playerid]);
TextDrawHideForPlayer(playerid, InfoSeconds[playerid]);
TextDrawHideForPlayer(playerid, InfoMinutes[playerid]);
return 1;
}
PHP:
stock HideTextdraws(playerid)
{
return 1;
}
PHP:
stock GetDayLet(d,m,y)
{
m-=2;
if(m<=0)
{
y--;
m+=12;
}
new cen = y/100;
y=getrem(y,100);
new w = d + ((13*m-1)/5) + y + (y/4) + (cen/4) - 2*cen;
w=getrem(w,7);
if (w==0) w=7;
return w-1;
}
getrem(a,b)
{
new div = a/b;
new left = a-b*div;
return left;
}
Заключение.
Часы тестированы на StrikeArena'e.
Удачи Вам в использовании.
Последнее редактирование:
