Advertisement
Jonny_5

SyncTime

Apr 18th, 2012
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.86 KB | None | 0 0
  1. //SyncTime By Jonny5
  2.  
  3.  
  4. #define FILTERSCRIPT
  5.  
  6. #include <a_samp>
  7. #define TD_FONT_COLOR           0xFFFFFFFF
  8. #define TD_OUTLINE_COLOR        0x000000FF
  9. #define TD_OUTLINE_SIZE         1
  10.  
  11. //if this is uncommented then it will use server time 1 real hour = 1 game hour
  12. //if commented it will use singleplayer time but sync for all players 1 real second = 1 game minute
  13. //#define SYNC_SERVER_TIME        
  14.  
  15.  
  16. new Hour, Minute,  TIMER_WorldTime;
  17. #if defined SYNC_SERVER_TIME
  18. new Second;
  19. #endif
  20. new Text:tdWorldTime;
  21. new PlayerIsSpawned[MAX_PLAYERS];
  22.  
  23.  
  24. #if defined FILTERSCRIPT
  25.  
  26. public OnFilterScriptInit()
  27. {
  28.     print("\n--------------------------------------");
  29.     print(" SyncTime By Jonny5");
  30.     print("--------------------------------------\n");
  31.     //gettime(Hour, Minute, Second);
  32.     //printf("%02d:%02d:%02d", Hour, Minute, Second);
  33.  
  34.     tdWorldTime = TextDrawCreate(605.0,25.0," ");
  35.     TextDrawUseBox          (tdWorldTime, 0);
  36.     TextDrawFont            (tdWorldTime, 3);
  37.     TextDrawColor           (tdWorldTime, TD_FONT_COLOR);
  38.     TextDrawSetOutline      (tdWorldTime, TD_OUTLINE_SIZE);
  39.     TextDrawBackgroundColor (tdWorldTime, TD_OUTLINE_COLOR);
  40.     TextDrawSetShadow       (tdWorldTime, 0);
  41.     TextDrawAlignment       (tdWorldTime, 3);
  42.     TextDrawLetterSize      (tdWorldTime, 0.5, 1.5);
  43.     TextDrawShowForAll      (tdWorldTime);
  44.     TIMER_WorldTime = SetTimer("UpdateWorldTime", 1000, true);
  45.  
  46.     return 1;
  47. }
  48.  
  49. public OnFilterScriptExit()
  50. {
  51.     KillTimer           (TIMER_WorldTime);
  52.     TextDrawHideForAll  (tdWorldTime);
  53.     TextDrawDestroy     (tdWorldTime);
  54.     return 1;
  55. }
  56.  
  57. #else
  58.  
  59. main()
  60. {
  61.     print("\n----------------------------------");
  62.     print("  SyncTime By Jonny5");
  63.     print("----------------------------------\n");
  64. }
  65.  
  66. #endif
  67.  
  68.  
  69.  
  70. public OnPlayerConnect(playerid)
  71. {
  72.     TogglePlayerClock(playerid, 0);
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerDisconnect(playerid, reason)
  77. {
  78.     PlayerIsSpawned[playerid] = 0;
  79.     return 1;
  80. }
  81.  
  82. public OnPlayerSpawn(playerid)
  83. {
  84.     PlayerIsSpawned[playerid] = 1;
  85.     SetPlayerTime(playerid,Hour,Minute);
  86.     TextDrawShowForPlayer(playerid,tdWorldTime);
  87.     return 1;
  88. }
  89.  
  90. public OnPlayerRequestClass(playerid, classid)
  91. {
  92.     TextDrawHideForPlayer(playerid,tdWorldTime);
  93.     PlayerIsSpawned[playerid] = 0;
  94.     return 1;
  95. }
  96.  
  97. forward UpdateWorldTime();
  98. public UpdateWorldTime()
  99. {
  100.     new str[10];
  101. #if defined SYNC_SERVER_TIME
  102.     gettime(Hour, Minute, Second);
  103. #else
  104.     Minute++;
  105.     if(Minute == 60)
  106.     {
  107.         Minute=0;
  108.         Hour++;
  109.     }
  110.     if(Hour == 24) Hour=0;
  111. #endif
  112.     format(str, sizeof(str), "%02d:%02d", Hour, Minute);
  113.     TextDrawSetString(tdWorldTime,str);
  114.     for(new i = 0,pl = GetMaxPlayers(); i < pl ;i++)
  115.     {
  116.         if(PlayerIsSpawned[i] == 1)
  117.         {
  118.             SetPlayerTime(i,Hour,Minute);
  119.         }
  120.     }
  121.     return 1;
  122. }
  123.  
  124.  
  125. public OnGameModeInit()
  126. {
  127.     return 1;
  128. }
  129.  
  130. public OnGameModeExit()
  131. {
  132.     return 1;
  133. }
  134.  
  135. public OnPlayerDeath(playerid, killerid, reason)
  136. {
  137.     return 1;
  138. }
  139.  
  140. public OnVehicleSpawn(vehicleid)
  141. {
  142.     return 1;
  143. }
  144.  
  145. public OnVehicleDeath(vehicleid, killerid)
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnPlayerText(playerid, text[])
  151. {
  152.     return 1;
  153. }
  154.  
  155. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  156. {
  157.     return 1;
  158. }
  159.  
  160. public OnPlayerExitVehicle(playerid, vehicleid)
  161. {
  162.     return 1;
  163. }
  164.  
  165. public OnPlayerStateChange(playerid, newstate, oldstate)
  166. {
  167.     return 1;
  168. }
  169.  
  170. public OnPlayerEnterCheckpoint(playerid)
  171. {
  172.     return 1;
  173. }
  174.  
  175. public OnPlayerLeaveCheckpoint(playerid)
  176. {
  177.     return 1;
  178. }
  179.  
  180. public OnPlayerEnterRaceCheckpoint(playerid)
  181. {
  182.     return 1;
  183. }
  184.  
  185. public OnPlayerLeaveRaceCheckpoint(playerid)
  186. {
  187.     return 1;
  188. }
  189.  
  190. public OnRconCommand(cmd[])
  191. {
  192.     return 1;
  193. }
  194.  
  195. public OnPlayerRequestSpawn(playerid)
  196. {
  197.     return 1;
  198. }
  199.  
  200. public OnObjectMoved(objectid)
  201. {
  202.     return 1;
  203. }
  204.  
  205. public OnPlayerObjectMoved(playerid, objectid)
  206. {
  207.     return 1;
  208. }
  209.  
  210. public OnPlayerPickUpPickup(playerid, pickupid)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnVehicleMod(playerid, vehicleid, componentid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  221. {
  222.     return 1;
  223. }
  224.  
  225. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  226. {
  227.     return 1;
  228. }
  229.  
  230. public OnPlayerSelectedMenuRow(playerid, row)
  231. {
  232.     return 1;
  233. }
  234.  
  235. public OnPlayerExitedMenu(playerid)
  236. {
  237.     return 1;
  238. }
  239.  
  240. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  241. {
  242.     return 1;
  243. }
  244.  
  245. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  246. {
  247.     return 1;
  248. }
  249.  
  250. public OnRconLoginAttempt(ip[], password[], success)
  251. {
  252.     return 1;
  253. }
  254.  
  255. public OnPlayerUpdate(playerid)
  256. {
  257.     return 1;
  258. }
  259.  
  260. public OnPlayerStreamIn(playerid, forplayerid)
  261. {
  262.     return 1;
  263. }
  264.  
  265. public OnPlayerStreamOut(playerid, forplayerid)
  266. {
  267.     return 1;
  268. }
  269.  
  270. public OnVehicleStreamIn(vehicleid, forplayerid)
  271. {
  272.     return 1;
  273. }
  274.  
  275. public OnVehicleStreamOut(vehicleid, forplayerid)
  276. {
  277.     return 1;
  278. }
  279.  
  280. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  281. {
  282.     return 1;
  283. }
  284.  
  285. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  286. {
  287.     return 1;
  288. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement