#include <a_samp> #include <sscanf2>
#define COLOR_TIME 0xFFFFFFFF #define COLOR_DAY 0xFFFFFFFF #define MINUTE 1000
forward GameDay();
new Text:gTime; new Text:gDay; new gtime=0; new gday=0; |
SetTimer("Gameday",MINUTE,1); gTime = TextDrawCreate(605.000000,25.000000,"00:00"); TextDrawAlignment(gTime,3); TextDrawBackgroundColor(gTime,0x000000FF); TextDrawFont(gTime,3); TextDrawLetterSize(gTime,0.535,2.2); TextDrawColor(gTime,COLOR_TIME); TextDrawSetOutline(gTime,2); TextDrawSetProportional(gTime,1); TextDrawSetShadow(gTime,1); gDay = TextDrawCreate(610.000000,7.000000,"Sunday"); TextDrawUseBox(gDay,0); TextDrawFont(gDay,3); TextDrawLetterSize(gDay,0.6,1.5); TextDrawSetShadow(gDay,1); TextDrawSetOutline(gDay ,0); TextDrawBackgroundColor(gDay, 0x000000FF); TextDrawBoxColor(gDay ,0x00000066); TextDrawColor(gDay,COLOR_DAY); TextDrawTextSize(gDay , -1880.0, -1880.0); TextDrawAlignment(gDay,3); TextDrawSetOutline(gDay,1);
public Gameday() { new timestring[256]; new daystring[256]; new gseconds = gtime % 60, gminutes = (gtime - gseconds) / 60; gtime ++; format(timestring, sizeof (timestring), " %02d:%02d", gminutes, gseconds); TextDrawSetString(gTime,timestring); TextDrawShowForAll(gTime); format(daystring, sizeof (daystring), "%s",GetDayName()); TextDrawSetString(gDay,daystring); TextDrawShowForAll(gDay); SetWorldTime(gminutes); if(gday==6&>ime==1440)//One week passed { gday=0; gtime=0; //A new week has begun } if(gtime==1440)//One day passed { gday++; gtime=0; format(daystring, sizeof (daystring), " 00:00"); TextDrawSetString(gTime,daystring); } return 1; }
stock GetDayName() { new DayName[128]; switch(gday) { //All day names can be changed to your language. case 0: format(DayName, sizeof(DayName), "Sunday"); case 1: format(DayName, sizeof(DayName), "Monday"); case 2: format(DayName, sizeof(DayName), "Tuesday"); case 3: format(DayName, sizeof(DayName), "Wednesday"); case 4: format(DayName, sizeof(DayName), "Thursday"); case 5: format(DayName, sizeof(DayName), "Friday"); case 6: format(DayName, sizeof(DayName), "Saturday"); } return DayName; }
Originally Posted by Forum Rules
No Double Posting - There is a modify button , use it. However, bumping a topic in which you have or require further information is allowed after at least 24 hours. Note that two identical posts appearing at the same time is usually a mistake attributed to lag, and will not be penalized (but the second one will be removed).
|
#include <a_samp>
#define COLOR_TIME 0xFFFFFFFF
#define COLOR_DAY 0xFFFFFFFF
#define MINUTE 1000
new Text:GameDay, Text:GameTime;
new gTimeMinutes, gTimeHours, gTimeDay;
public OnGameModeInit()
{
gTimeMinutes = gTimeHours = gTimeDay = 0;
SetTimer("GameTimeUpdate", MINUTE, true);
GameTime = TextDrawCreate(605.000000, 25.000000, "00:00");
TextDrawAlignment(GameTime, 3);
TextDrawBackgroundColor(GameTime, 0x000000FF);
TextDrawFont(GameTime, 3);
TextDrawLetterSize(GameTime, 0.535, 2.2);
TextDrawColor(GameTime, COLOR_TIME);
TextDrawSetOutline(GameTime, 2);
TextDrawSetProportional(GameTime, 1);
TextDrawSetShadow(GameTime, 1);
GameDay = TextDrawCreate(610.000000, 7.000000, "Sunday");
TextDrawUseBox(GameDay, 0);
TextDrawFont(GameDay, 3);
TextDrawLetterSize(GameDay, 0.6, 1.5);
TextDrawSetShadow(GameDay, 1);
TextDrawSetOutline(GameDay, 0);
TextDrawBackgroundColor(GameDay, 0x000000FF);
TextDrawBoxColor(GameDay, 0x00000066);
TextDrawColor(GameDay, COLOR_DAY);
TextDrawTextSize(GameDay, -1880.0, -1880.0);
TextDrawAlignment(GameDay, 3);
TextDrawSetOutline(GameDay, 1);
return 1;
}
forward GameTimeUpdate();
public GameTimeUpdate()
{
if((gTimeMinutes++) >= 59)
{
gTimeMinutes -= 60;
//New hour
if((gTimeHours++) >= 23)
{
gTimeHours -= 24;
//New day
if((gTimeDay++) >= 6)
{
gTimeDay = 0;
//New week
}
}
}
new timestring[15];
format(timestring, sizeof(timestring), " %02d:%02d", gTimeHours, gTimeMinutes);
TextDrawSetString(GameTime, timestring);
TextDrawShowForAll(GameTime);
format(timestring, sizeof(timestring), "%s", GetDayName());
TextDrawSetString(GameDay, timestring);
TextDrawShowForAll(GameDay);
SetWorldTime(gTimeHours);
return 1;
}
GetDayName()
{
new day[10];
switch(gTimeDay)
{
case 1: day = "Monday";
case 2: day = "Tuesday";
case 3: day = "Wednesday";
case 4: day = "Thursday";
case 5: day = "Friday";
case 6: day = "Saturday";
default: day = "Sunday";
}
return day;
}