Guest User

Atime

a guest
Apr 9th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. ////------------------------------------////
  2. ////Admigo's Gametime+Gameday System 1.3////
  3. ////------------------------------------////
  4.  
  5. //Includes//
  6. #include <a_samp>
  7. #include <sscanf2>
  8. //--------//
  9.  
  10. //Defines//
  11. #define COLOR_TIME 0xFFFFFFFF //Change the colour of the time textdraw here
  12. #define COLOR_DAY 0xFFFFFFFF //Change the colour of the day textdraw here
  13. #define MINUTE 1000
  14. #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  15. #define COLOR_RED 0xFF0000AA
  16. #define COLOR_YELLOW 0xFFFF00AA
  17. #define COLOR_WHITE 0xFFFFFFAA
  18. //-------//
  19.  
  20. //Forwards//
  21. forward Timer();
  22. //--------//
  23.  
  24. //New Defines//
  25. new Text:gTime;
  26. new Text:gDay;
  27. new gtime=0;
  28. new gday=0;
  29. new N11=0;
  30. //-----------//
  31.  
  32. //Publics//
  33. public OnFilterScriptInit()
  34. {
  35. print("\n--------------------------------------");
  36. print(" Admigo's Gametime+Gameday System 1.3");
  37. print("--------------------------------------\n");
  38.  
  39. SetTimer("Timer",MINUTE,1);//
  40.  
  41. gTime = TextDrawCreate(605.000000,25.000000,"00:00");
  42. TextDrawAlignment(gTime,3);
  43. TextDrawBackgroundColor(gTime,0x000000FF);
  44. TextDrawFont(gTime,3);
  45. TextDrawLetterSize(gTime,0.535,2.2);
  46. TextDrawColor(gTime,COLOR_TIME);
  47. TextDrawSetOutline(gTime,2);
  48. TextDrawSetProportional(gTime,1);
  49. TextDrawSetShadow(gTime,1);
  50.  
  51. gDay = TextDrawCreate(610.000000,7.000000,"Sunday");
  52. TextDrawUseBox(gDay,0);
  53. TextDrawFont(gDay,3);
  54. TextDrawLetterSize(gDay,0.6,1.5);
  55. TextDrawSetShadow(gDay,1);
  56. TextDrawSetOutline(gDay ,0);
  57. TextDrawBackgroundColor(gDay, 0x000000FF);
  58. TextDrawBoxColor(gDay ,0x00000066);
  59. TextDrawColor(gDay,COLOR_DAY);
  60. TextDrawTextSize(gDay , -1880.0, -1880.0);
  61. TextDrawAlignment(gDay,3);
  62. TextDrawSetOutline(gDay,1);
  63. return 1;
  64. }
  65.  
  66. public OnFilterScriptExit()
  67. {
  68. return 1;
  69. }
  70.  
  71. public OnPlayerCommandText(playerid,cmdtext[])
  72. {
  73. dcmd(settime,7,cmdtext);
  74. dcmd(setday,6,cmdtext);
  75. return 0;
  76. }
  77. public OnPlayerConnect(playerid)
  78. {
  79. SendClientMessage(playerid,COLOR_YELLOW,"This server uses Admigo's Gametime+Gameday System 1.3");
  80. return 1;
  81. }
  82. public Timer()
  83. {
  84. new timestring[256];
  85. new daystring[256];
  86. new gseconds = gtime % 60,
  87. gminutes = (gtime - gseconds) / 60;
  88. gtime ++;
  89. format(timestring, sizeof (timestring), " %02d:%02d", gminutes, gseconds);
  90. TextDrawSetString(gTime,timestring);
  91. TextDrawShowForAll(gTime);
  92. format(daystring, sizeof (daystring), "%s",GetDayName());
  93. TextDrawSetString(gDay,daystring);
  94. TextDrawShowForAll(gDay);
  95. if(gday==6&&gtime==1440)//One week passed
  96. {
  97. gday=0;
  98. gtime=0;
  99. //A new week has begun
  100. }
  101. if(gtime==1440)//One day passed
  102. {
  103. gday++;
  104. gtime=0;
  105. format(daystring, sizeof (daystring), " 00:00");
  106. TextDrawSetString(gTime,daystring);
  107. }
  108. for(new i=0; i<MAX_PLAYERS; i++)
  109. {
  110. if(IsPlayerConnected(i))
  111. {
  112. SetPlayerTime( i, gminutes, gseconds);
  113. }
  114. }
  115. return 1;
  116. }
  117. //-------//
  118.  
  119. //Dcmd Commands//
  120. dcmd_settime(playerid,params[])
  121. {
  122. new string[128];
  123. new N1,N2;
  124. new pname[24];
  125. GetPlayerName(playerid,pname,sizeof(pname));
  126. if(!IsPlayerAdmin(playerid))
  127. {
  128. SendClientMessage(playerid,COLOR_RED,"You need to be an admin to use this command!");
  129. return 1;
  130. }
  131. if(sscanf(params, "ii", N1,N2))
  132. {
  133. SendClientMessage(playerid,COLOR_RED,"USAGE: /settime (Hour) (Minute)");
  134. return 1;
  135. }
  136. if(N1 < 0 || N1 > 23)
  137. {
  138. SendClientMessage(playerid,COLOR_RED,"Please enter an amount between 0 and 23.");
  139. return 1;
  140. }
  141. if(N2 < 0 || N2 > 59)
  142. {
  143. SendClientMessage(playerid,COLOR_RED,"Please enter an amount between 0 and 59.");
  144. return 1;
  145. }
  146. N11= N1 * 60;
  147. gtime=N11 + N2;
  148. format(string,sizeof(string),"%s(%d) has changed the time to %02d:%02d!",pname,playerid,N1,N2);
  149. SendClientMessageToAll(COLOR_YELLOW,string);
  150. return 1;
  151. }
  152.  
  153. dcmd_setday(playerid,params[])
  154. {
  155. new string[128];
  156. new N1;
  157. new pname[24];
  158. GetPlayerName(playerid,pname,sizeof(pname));
  159. if(!IsPlayerAdmin(playerid))
  160. {
  161. SendClientMessage(playerid,COLOR_RED,"You need to be an admin to use this command!");
  162. return 1;
  163. }
  164. if(sscanf(params, "i", N1))
  165. {
  166. SendClientMessage(playerid,COLOR_RED,"USAGE: /setday (Day)");
  167. return 1;
  168. }
  169. if(N1 < 0 || N1 > 6)
  170. {
  171. SendClientMessage(playerid,COLOR_RED,"Please enter an amount between 0 and 6.");
  172. return 1;
  173. }
  174. gday=N1;
  175. format(string,sizeof(string),"%s(%d) has changed the day to %s!",pname,playerid,GetDayName());
  176. SendClientMessageToAll(COLOR_YELLOW,string);
  177. return 1;
  178. }
  179. //-------------//
  180.  
  181.  
  182. //Stocks//
  183. stock GetDayName()
  184. {
  185. new DayName[128];
  186. switch(gday)
  187. {
  188. //All day names can be changed to your language.
  189. case 0: format(DayName, sizeof(DayName), "Sunday");
  190. case 1: format(DayName, sizeof(DayName), "Monday");
  191. case 2: format(DayName, sizeof(DayName), "Tuesday");
  192. case 3: format(DayName, sizeof(DayName), "Wednesday");
  193. case 4: format(DayName, sizeof(DayName), "Thursday");
  194. case 5: format(DayName, sizeof(DayName), "Friday");
  195. case 6: format(DayName, sizeof(DayName), "Saturday");
  196. }
  197. return DayName;
  198. }
  199. //------//
Advertisement
Add Comment
Please, Sign In to add comment