Guest User

[FS]Custom Clock Speed

a guest
Jun 4th, 2011
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #if defined FILTERSCRIPT
  4.  
  5. #define CLOCKSPEED 3 //How much faster the in-game time is compared to the real time. Higher numbers is faster speed, Lower numbers is slower speed
  6.  
  7. new Text:Clock; //The clock textdraw
  8. new hour, minute; //The hours and minutes for the textdraw
  9.  
  10. forward Time(); //Forward for the timer
  11.  
  12. public OnFilterScriptInit()
  13. {
  14. print("\n====================================="
  15. print("Custom Clock Speed FS. Made by 1D10T."
  16. print("=====================================\n"
  17. return 1;
  18. }
  19.  
  20. public OnGameModeInit()
  21. {
  22. Clock = TextDrawCreate( 549, 24, "00:00" ); //The textdraw itself
  23. TextDrawLetterSize( Clock, 0.55, 2 );
  24. TextDrawFont( Clock, 3 );
  25. TextDrawBackgroundColor( Clock, 0x000000AA );
  26. TextDrawSetOutline( Clock, 2 );
  27.  
  28. SetTimer( "Time", 60000, 1 ); //Every minute the textdraw update function will be called
  29.  
  30. return 1;
  31. }
  32.  
  33. public Time() //Where the 'magic' happens
  34. {
  35. new string[128];
  36.  
  37. if( hour <= 23 )
  38. {
  39. if( minute <= 60/CLOCKSPEED-1 ) //Maximum number of minutes
  40. {
  41. if( minute < 4 ) //Please edit this one yourself since this is different per GAMESPEED. this is called when the minutes are less then 10. In this case 3x3=9 and 4x3=12
  42. {
  43. format( string, 25, "%d:0%d", hour, minute*CLOCKSPEED ); //
  44. minute++; //adds one to the minute of the function
  45. }
  46. else
  47. {
  48. format( string, 25, "%d:%d", hour, minute*CLOCKSPEED );
  49. minute++; //adds one to the minute of the function
  50. }
  51. }
  52. else
  53. {
  54. if( minute == 60/CLOCKSPEED ) //makes it nexthour:00 instead of going from currenthour:60 to nexthour:00
  55. {
  56. minute = 0; //resets the minute so it can continue itself
  57. hour++; //Adds one to the hour of the function
  58. format( string, 25, "%d:0%d", hour, minute*CLOCKSPEED );
  59. SetWorldTime( hour ); //Syncs the time with the time effect of the game (light and dark)
  60. }
  61. }
  62. }
  63. else
  64. {
  65. if( hour == 24 ) //makes it 0:00 instead of going from 24:00 to 0:00
  66. {
  67. hour = 0; //resets the hour so it can continue itself
  68. format( string, 25, "%d:0%d", hour, minute*CLOCKSPEED );
  69. SetWorldTime( hour );
  70. }
  71. }
  72.  
  73. for(new i = 0; i < MAX_PLAYERS; i++) //Assuming you won't get errors with the MAX_PLAYERS since this is pretty much a basic structure for every script
  74. {
  75. TextDrawHideForPlayer( i, Clock ); //removes the current textdraw
  76. TextDrawSetString( Clock, string ); //Updates the new time
  77. TextDrawShowForPlayer( i, Clock ); //Shows the updated clock
  78. }
  79. return 1;
  80. }
  81.  
  82. public OnPlayerSpawn( playerid )
  83. {
  84. TextDrawShowForPlayer( playerid, Clock ); //Show the clock after you have spawned (whatever the reason) because textdraws are destroyed after a respawn
  85. }
  86.  
  87. #endif
Advertisement
Add Comment
Please, Sign In to add comment