Advertisement
System32

S32_Time

Sep 12th, 2011
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.22 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_commands>
  3. #include <sscanf2>
  4.  
  5. new Tseconds, Tminutes, Thours;
  6. new Text: Time;
  7.  
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n");
  11.     print("  \4\4\4\4\4\4\4\4\4\4\4\4");
  12.     print("  \4 S32Time  \4");
  13.     print("  \4 by       \4");
  14.     print("  \4 System32 \4");
  15.     print("  \4\4\4\4\4\4\4\4\4\4\4\4\n");
  16.    
  17.     Time = TextDrawCreate(555.000000, 10.000000, "00:00:00");
  18.     TextDrawBackgroundColor(Time, 255);
  19.     TextDrawFont(Time, 1);
  20.     TextDrawLetterSize(Time, 0.500000, 1.000000);
  21.     TextDrawColor(Time, -65281);
  22.     TextDrawSetOutline(Time, 0);
  23.     TextDrawSetProportional(Time, 1);
  24.     TextDrawSetShadow(Time, 1);
  25.    
  26.     Tseconds = 0;
  27.     Tminutes = 9;
  28.     Thours = 8;
  29.    
  30.     SetTimer("TimeUp", 1000, true);
  31.     return 1;
  32. }
  33.  
  34. public OnFilterScriptExit()
  35. {
  36.     TextDrawDestroy(Time);
  37.     return 1;
  38. }
  39.  
  40. forward TimeUp();
  41. public TimeUp()
  42. {
  43.     new string[128];
  44.     Tseconds += 1;
  45.     if(Tseconds == 60)
  46.     {
  47.         Tseconds = 0;
  48.         Tminutes += 1;
  49.     }
  50.     if(Tminutes == 60)
  51.     {
  52.         Tseconds = 0;
  53.         Tminutes = 0;
  54.         Thours += 1;
  55.     }
  56.     if(Thours == 24)
  57.     {
  58.         Tseconds += 1;
  59.         Tminutes = 0;
  60.         Thours = 0;
  61.     }
  62.     if(Thours < 10 || Tminutes < 10 || Tseconds < 10)
  63.     {
  64.         format(string, sizeof(string), "%02d:%02d:%02d", Thours, Tminutes, Tseconds);
  65.     }
  66.     else if(Thours >= 10 || Tminutes >= 10 || Tseconds >= 10)
  67.     {
  68.         format(string, sizeof(string), "%d:%d:%d", Thours, Tminutes, Tseconds);
  69.     }
  70.     for(new i; i < MAX_PLAYERS; i++)
  71.     {
  72.         if(!IsPlayerConnected(i)) continue;
  73.         SetPlayerTime(i, Thours, Tminutes);
  74.     }
  75.     TextDrawSetString(Time, string);
  76. }
  77.  
  78. YCMD:settime(playerid, params[], help)
  79. {
  80.     #pragma unused help
  81.     if(IsPlayerAdmin(playerid))
  82.     {
  83.         if(sscanf(params, "dd", Thours, Tminutes)) return SendClientMessage(playerid, -1, "Usage: /settime [Hours][Minutes]");
  84.         else if(Thours < 0 || Thours > 24) return SendClientMessage(playerid, -1, "Hours must be between 0 & 24!");
  85.         else if(Tminutes < 0 || Tminutes > 60) return SendClientMessage(playerid, -1, "Minutes must be between 0 & 60!");
  86.         else
  87.         for(new i; i < MAX_PLAYERS; i++)
  88.         {
  89.             SetPlayerTime(i, Thours, Tminutes);
  90.         }
  91.     }
  92.     return 1;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement