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
- 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()
- {
- Clock = TextDrawCreate( 549, 24, "00:00" ); //The textdraw itself
- TextDrawLetterSize( Clock, 0.55, 2 );
- TextDrawFont( Clock, 3 );
- TextDrawBackgroundColor( Clock, 0x000000AA );
- TextDrawSetOutline( Clock, 2 );
- SetTimer( "Time", 60000, 1 ); //Every minute the textdraw update function will be called
- return 1;
- }
- public Time() //Where the 'magic' happens
- {
- new string[128];
- if( hour <= 23 )
- {
- if( minute <= 60/CLOCKSPEED-1 ) //Maximum number of minutes
- {
- 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
- {
- format( string, 25, "%d:0%d", hour, minute*CLOCKSPEED ); //
- minute++; //adds one to the minute of the function
- }
- else
- {
- format( string, 25, "%d:%d", hour, minute*CLOCKSPEED );
- minute++; //adds one to the minute of the function
- }
- }
- else
- {
- if( minute == 60/CLOCKSPEED ) //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*CLOCKSPEED );
- 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*CLOCKSPEED );
- 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
- }
- 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