BigETI

Time.pwn

Nov 17th, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.13 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #define MAX_MINUTES 60
  4. #define MAX_HOURS   24
  5. new Text:Clock, gTime[2];
  6. stock UpdateTime()
  7. {
  8.     new tstr[10];
  9.     format(tstr, 10, "%02d:%02d", gTime[0], gTime[1]);
  10.     TextDrawSetString(Clock, tstr);
  11.     for(new playerid = 0; playerid < MAX_PLAYERS; playerid++) if(IsPlayerConnected(playerid)) SetPlayerTime(playerid, gTime[0], gTime[1]);
  12. }
  13. forward Tick();
  14. public OnFilterScriptInit()
  15. {
  16.     Clock = TextDrawCreate(547.0, 24.0, "--:--");
  17.     TextDrawLetterSize(Clock, 0.6, 2.0);
  18.     TextDrawFont(Clock, 3);
  19.     TextDrawSetOutline(Clock, 2);
  20.     gTime[0] = random(MAX_HOURS);
  21.     gTime[1] = random(MAX_MINUTES);
  22.     UpdateTime();
  23.     TextDrawShowForAll(Clock);
  24.     SetTimer("Tick", 1000, true);
  25.     return 1;
  26. }
  27. public OnFilterScriptExit()
  28. {
  29.     TextDrawDestroy(Clock);
  30.     return 1;
  31. }
  32. public OnPlayerConnect(playerid)
  33. {
  34.     TextDrawShowForPlayer(playerid, Clock);
  35.     return 1;
  36. }
  37. public Tick()
  38. {
  39.     new tTime[2];
  40.     tTime[0] = gTime[0];
  41.     tTime[1] = gTime[1]+1;
  42.     if(tTime[1] >= MAX_MINUTES)
  43.     {
  44.         tTime[1] = 0;
  45.         tTime[0]++;
  46.     }
  47.     if(tTime[0] >= MAX_HOURS) tTime[0] = 0;
  48.     gTime[0] = tTime[0];
  49.     gTime[1] = tTime[1];
  50.     UpdateTime();
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment