Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #if defined FILTERSCRIPT
- #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
- #define CLOCKCYCLE 24 //24-hour clock or 12-hour clock
- new Text:Clock; //The clock textdraw
- new hour, minute; //The hours and minutes for the textdraw
- forward Time(); //Forward for the timer
- public OnFilterScriptInit()
- {
- print("\n====================================="
- print("Custom Clock Speed FS. Made by 1D10T."
- print("=====================================\n"
- return 1;
- }
- public OnGameModeInit()
- {
- if(CLOCKCYCLE == 24)
- {
- Clock = TextDrawCreate( 549, 24, "0:00" ); //The textdraw itself
- TextDrawLetterSize( Clock, 0.55, 2 );
- TextDrawFont( Clock, 3 );
- TextDrawBackgroundColor( Clock, 0x000000AA );
- TextDrawSetOutline( Clock, 2 );
- }
- else
- {
- if(CLOCKCYCLE == 12)
- {
- Clock = TextdrawCreate( 549, 24, "00:00 - AM );
- TextDrawLetterSize( Clock, 0.55, 2 );
- TextDrawFront( Clock, 3 );
- TextDrawBackgroundColor( Clock, 0x000000AA );
- TextDrawSetOutLine( Clock, 2 );
- }
- }
- SetWorldTime( 0 );
- SetTimer( "Time", 1/CLOCKSPEED*60000, 1 ); //1 is devided by the clockspeed and then multiplied by 60000milliseconds (1 mintue)
- return 1;
- }
- public Time() //Where the 'magic' happens
- {
- new string[128];
- if( CLOCKCYCLE == 24 ) //24 Hour clock
- {
- if( hour <= 23 )
- {
- if( minute <= 59 ) //End of the hour
- {
- if( minute <= 9 ) //For making 0:09 instead of 0:9
- {
- format( string, 25, "%d:0%d", hour, minute );
- minute++; //adds one to the minute of the function
- }
- else
- {
- format( string, 25, "%d:%d", hour, minute );
- minute++;
- }
- }
- else
- {
- if( minute == 60 ) //makes it nexthour:00 instead of going from currenthour:60 to nexthour:00
- {
- minute = 0; //resets the minute so it can continue itself
- hour++; //Adds one to the hour of the function
- format( string, 25, "%d:0%d", hour, minute );
- SetWorldTime( hour ); //Syncs the time with the time effect of the game (light and dark)
- }
- }
- }
- else
- {
- if( hour == 24 ) //makes it 0:00 instead of going from 24:00 to 0:00
- {
- hour = 0; //resets the hour so it can continue itself
- format( string, 25, "%d:0%d", hour, minute );
- SetWorldTime( hour );
- }
- }
- 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
- {
- TextDrawHideForPlayer( i, Clock ); //removes the current textdraw
- TextDrawSetString( Clock, string ); //Updates the new time
- TextDrawShowForPlayer( i, Clock ); //Shows the updated clock
- }
- }
- else
- {
- if( CLOCKCYCLE == 12 ) //12 Hour clock
- {
- if( hour <= 23 )
- {
- if( hour <= 12 )
- {
- if( minute <= 59 )
- {
- if( minute <= 9 )
- {
- format( string, 25, "%d:0%d - AM );
- minute++;
- }
- else
- {
- format( string, 25, "%d:%d - AM );
- minute++;
- }
- }
- else
- {
- if( minute == 60 )
- {
- if( hour <= 11 ) //When its before 12AM
- {
- minute = 0;
- hour++;
- format( string, 25, "%d:0%d - AM", hour, minute );
- SetWorldTime( hour );
- }
- else
- {
- if( hour == 12 ) //When its 12AM
- {
- minute = 0;
- hour++;
- format( string, 25, "%d:0%d - PM", hour-12, minute );
- SetWorldTime( hour );
- }
- }
- }
- }
- }
- else
- {
- if( hour >= 13 )
- {
- if( minute <= 59 )
- {
- if( mintue <= 9 )
- {
- format( string, 25, "%d:0%d - PM", hour-12, minute );
- minute++;
- }
- else
- {
- format( string, 25, "%d:%d - PM", hour-12, minute );
- minute++;
- }
- }
- else
- {
- if( minute == 60 )
- {
- if( hour <= 23 ) //When its before 12PM
- {
- minute = 0;
- hour++;
- format( string, 25, "%d:0%d - PM", hour-12, minute );
- SetWorldTime( hour );
- }
- else
- {
- if( hour == 24 )
- {
- minute = 0;
- hour = 0;
- format( string, 25, "%d:0%d - AM", hour, minute );
- SetWorldTime( hour );
- }
- }
- }
- }
- }
- }
- }
- }
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- TextDrawHideForPlayer( i, Clock );
- TextDrawSetString( Clock, string );
- TextDrawShowForPlayer( i, Clock );
- }
- }
- return 1;
- }
- public OnPlayerSpawn( playerid )
- {
- TextDrawShowForPlayer( playerid, Clock ); //Show the clock after you have spawned (whatever the reason) because textdraws are destroyed after a respawn
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment