Darky

Digital Clock [v1.0]

Mar 15th, 2013
2,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.16 KB | None | 0 0
  1. //______________________________________________________________________________
  2.  
  3. #if defined Digital_Clock_v_1_0
  4.  
  5. // o.OOOo.   ooOoOOo  .oOOOo.  ooOoOOo oOoOOoOOo    Oo   o
  6.    O    `o     O    .O     o     O        o       o  O   O
  7. // o      O    o    o            o        o      O    o  o
  8.    O      o    O    O            O        O     oOooOoOo o
  9. // o      O    o    O   .oOOo    o        o     o      O O
  10.    O      o    O    o.      O    O        O     O      o O
  11. // o    .O'    O     O.    oO    O        O     o      O o     .
  12.    OooOO'   ooOOoOo   `OooO'  ooOOoOo     o'    O.     O OOoOooO
  13.  
  14. // Made by DarkyTheAngel aka Darky!
  15.  
  16. //  .oOOOo.   o       .oOOOo.   .oOOOo.  `o    O
  17.   .O     o  O       .O     o. .O     o   o   O
  18. // o         o       O       o o          O  O
  19.   o         o       o       O o          oOo
  20. // o         O       O       o o          o  o
  21.   O         O       o       O O          O   O
  22. // `o     .o o     . `o     O' `o     .o  o    o
  23.     `OoooO'  OOoOooO  `OoooO'   `OoooO'   O     O
  24.  
  25. #endif
  26.  
  27. //______________________________________________________________________________
  28.  
  29. #include                                                      "     a_samp     "
  30.  
  31. #include                                                      "       zcmd     "
  32.  
  33. //______________________________________________________________________________
  34.  
  35. #define W                                                             "{FFFFFF}"
  36.  
  37. #define R                                                             "{A10000}"
  38.  
  39. #define G                                                             "{3EA100}"
  40.  
  41. //______________________________________________________________________________
  42.  
  43. new
  44.  
  45.     Text:ClockTextdraw [ 8           ] ,
  46.    
  47.     StartClock         [ MAX_PLAYERS ] ,
  48.    
  49.     StopClock          [ MAX_PLAYERS ] ,
  50.    
  51.     bool:IsActive      [ MAX_PLAYERS ]
  52.  
  53. ;
  54.  
  55. //______________________________________________________________________________
  56.  
  57. public OnFilterScriptInit ( )
  58.  
  59. {
  60.  
  61.     ClockTextdraw [ 0 ] = TextDrawCreate ( 489.375000          , 385.583404 , "_"       ) ;
  62.  
  63.     TextDrawLetterSize                   ( ClockTextdraw [ 0 ] , 0.536248   , 4.434998  ) ;
  64.  
  65.     TextDrawTextSize                     ( ClockTextdraw [ 0 ] , 581.875000 , 1.749999  ) ;
  66.  
  67.     TextDrawUseBox                       ( ClockTextdraw [ 0 ] , true                   ) ;
  68.    
  69.     TextDrawBoxColor                     ( ClockTextdraw [ 0 ] , 255                    ) ;
  70.    
  71.     TextDrawSetOutline                   ( ClockTextdraw [ 0 ] , -1                     ) ;
  72.  
  73. //______________________________________________________________________________
  74.  
  75.     ClockTextdraw [ 1 ] = TextDrawCreate ( 580.625000          , 371.000030 , ")"       ) ;
  76.    
  77.     TextDrawLetterSize                   ( ClockTextdraw [ 1 ] , 0.474375   , 6.126666  ) ;
  78.    
  79.     TextDrawFont                         ( ClockTextdraw [ 1 ] , 1                      ) ;
  80.    
  81.     TextDrawColor                        ( ClockTextdraw [ 1 ] , 255                    ) ;
  82.    
  83.     TextDrawSetOutline                   ( ClockTextdraw [ 1 ] , 1                      ) ;
  84.    
  85.     TextDrawFont                         ( ClockTextdraw [ 1 ] , 1                      ) ;
  86.  
  87.     TextDrawAlignment                    ( ClockTextdraw [ 1 ] , 1                      ) ;
  88.    
  89.     TextDrawSetShadow                    ( ClockTextdraw [ 1 ] , 0                      ) ;
  90.    
  91. //______________________________________________________________________________
  92.  
  93.     ClockTextdraw [ 2 ] = TextDrawCreate ( 484.125000          , 372.000030 , "("       ) ;
  94.    
  95.     TextDrawLetterSize                   ( ClockTextdraw [ 2 ] , 0.474375   , 6.126666  ) ;
  96.    
  97.     TextDrawFont                         ( ClockTextdraw [ 2 ] , 1                      ) ;
  98.    
  99.     TextDrawColor                        ( ClockTextdraw [ 2 ] , 255                    ) ;
  100.  
  101.     TextDrawSetOutline                   ( ClockTextdraw [ 2 ] , 1                      ) ;
  102.  
  103.     TextDrawFont                         ( ClockTextdraw [ 2 ] , 1                      ) ;
  104.  
  105.     TextDrawAlignment                    ( ClockTextdraw [ 2 ] , 1                      ) ;
  106.  
  107.     TextDrawSetShadow                    ( ClockTextdraw [ 2 ] , 0                      ) ;
  108.  
  109. //______________________________________________________________________________
  110.  
  111.     ClockTextdraw [ 3 ] = TextDrawCreate ( 491.250000          , 387.916748 , "_"       ) ;
  112.    
  113.     TextDrawLetterSize                   ( ClockTextdraw [ 3 ] , 0.365624   , -0.266665 ) ;
  114.    
  115.     TextDrawTextSize                     ( ClockTextdraw [ 3 ] , 579.375000 , -6.416666 ) ;
  116.    
  117.     TextDrawColor                        ( ClockTextdraw [ 3 ] , 1296911648             ) ;
  118.    
  119.     TextDrawUseBox                       ( ClockTextdraw [ 3 ] , true                   ) ;
  120.    
  121.     TextDrawBoxColor                     ( ClockTextdraw [ 3 ] , 1296911648             ) ;
  122.  
  123. //______________________________________________________________________________
  124.  
  125.     ClockTextdraw [ 4 ] = TextDrawCreate ( 493.500000          , 424.833221 , "_"       ) ;
  126.    
  127.     TextDrawLetterSize                   ( ClockTextdraw [ 4 ] , 0.365624   , -0.266665 ) ;
  128.    
  129.     TextDrawTextSize                     ( ClockTextdraw [ 4 ] , 579.375000 , -6.416666 ) ;
  130.    
  131.     TextDrawColor                        ( ClockTextdraw [ 4 ] , 1296911648             ) ;
  132.    
  133.     TextDrawUseBox                       ( ClockTextdraw [ 4 ] , true                   ) ;
  134.    
  135.     TextDrawBoxColor                     ( ClockTextdraw [ 4 ] , 1296911648             ) ;
  136.  
  137. //______________________________________________________________________________
  138.  
  139.     ClockTextdraw [ 5 ] = TextDrawCreate ( 490.000000          , 385.000061 , "99:99"   ) ;
  140.    
  141.     TextDrawLetterSize                   ( ClockTextdraw [ 5 ] , 0.721875   , 3.682500  ) ;
  142.    
  143.     TextDrawColor                        ( ClockTextdraw [ 5 ] , 1296911664             ) ;
  144.    
  145.     TextDrawFont                         ( ClockTextdraw [ 5 ] , 2                      ) ;
  146.  
  147. //______________________________________________________________________________
  148.  
  149.     ClockTextdraw [ 6 ] = TextDrawCreate ( 529.375000          , 388.500061 , ":"       ) ;
  150.    
  151.     TextDrawLetterSize                   ( ClockTextdraw [ 6 ] , 0.679375   , 3.017501  ) ;
  152.    
  153.     TextDrawColor                        ( ClockTextdraw [ 6 ] , 7709695                ) ;
  154.    
  155.     TextDrawSetOutline                   ( ClockTextdraw [ 6 ] , 1                      ) ;
  156.    
  157.     TextDrawFont                         ( ClockTextdraw [ 6 ] , 2                      ) ;
  158.    
  159. //______________________________________________________________________________
  160.  
  161.     ClockTextdraw [ 7 ] = TextDrawCreate ( 490.625000          , 387.916656 , "00 00"   ) ;
  162.    
  163.     TextDrawLetterSize                   ( ClockTextdraw [ 7 ] , 0.705000   , 3.332500  ) ;
  164.    
  165.     TextDrawColor                        ( ClockTextdraw [ 7 ] , 7709695                ) ;
  166.    
  167.     TextDrawSetOutline                   ( ClockTextdraw [ 7 ] , 1                      ) ;
  168.    
  169.     TextDrawFont                         ( ClockTextdraw [ 7 ] , 2                      ) ;
  170.  
  171. //______________________________________________________________________________
  172.  
  173.    SetTimer ( "GetPlayerTimeEx" , 1000 , true ) ;
  174.  
  175.     return ( 1 ) ;
  176.  
  177. }
  178.  
  179. //______________________________________________________________________________
  180.  
  181. public OnPlayerDisconnect ( playerid , reason )
  182.  
  183. {
  184.  
  185.     KillTimer ( StartClock [ playerid ] ) ;
  186.    
  187.     KillTimer ( StopClock  [ playerid ] ) ;
  188.    
  189.     IsActive [ playerid ] = false ;
  190.    
  191.     return ( 1 ) ;
  192.  
  193. }
  194.  
  195. //______________________________________________________________________________
  196.  
  197. public OnPlayerSpawn ( playerid )
  198.  
  199. {
  200.  
  201.     StartClock [ playerid ] = SetTimerEx ( "ActiveClock" , 350 , 0 , "i" , playerid ) ;
  202.  
  203.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 0 ] ) ;
  204.    
  205.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 1 ] ) ;
  206.    
  207.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 2 ] ) ;
  208.    
  209.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 3 ] ) ;
  210.    
  211.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 4 ] ) ;
  212.    
  213.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 5 ] ) ;
  214.    
  215.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  216.    
  217.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 7 ] ) ;
  218.    
  219.     IsActive [ playerid ] = true ;
  220.    
  221.     return ( 1 ) ;
  222.  
  223. }
  224.  
  225. //______________________________________________________________________________
  226.  
  227. public OnPlayerRequestClass ( playerid , classid )
  228.  
  229. {
  230.  
  231.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 0 ] ) ;
  232.  
  233.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 1 ] ) ;
  234.  
  235.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 2 ] ) ;
  236.  
  237.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 3 ] ) ;
  238.    
  239.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 4 ] ) ;
  240.    
  241.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 5 ] ) ;
  242.    
  243.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  244.    
  245.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 7 ] ) ;
  246.    
  247.     IsActive [ playerid ] = false ;
  248.  
  249.     return ( 1 ) ;
  250.  
  251. }
  252.  
  253. //______________________________________________________________________________
  254.  
  255. forward ActiveClock ( playerid ) ;
  256.  
  257. public ActiveClock ( playerid )
  258.  
  259. {
  260.  
  261.     TextDrawHideForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  262.    
  263.     KillTimer ( StartClock [ playerid ] ) ;
  264.    
  265.     StopClock [ playerid ] = SetTimerEx ( "DisableClock" , 350 , 0 , "i" , playerid ) ;
  266.    
  267. }
  268.  
  269. //______________________________________________________________________________
  270.  
  271. forward DisableClock ( playerid ) ;
  272.  
  273. public DisableClock ( playerid )
  274.  
  275. {
  276.  
  277.     TextDrawShowForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  278.  
  279.     KillTimer ( StopClock [ playerid ] ) ;
  280.  
  281.     StartClock [ playerid ] = SetTimerEx ( "ActiveClock" , 350 , 0 , "i" , playerid ) ;
  282.  
  283. }
  284.  
  285. //______________________________________________________________________________
  286.  
  287. forward GetPlayerTimeEx ( playerid ) ;
  288.  
  289. public GetPlayerTimeEx ( playerid )
  290.  
  291. {
  292.  
  293.     new
  294.  
  295.         string [   28   ] ,
  296.  
  297.         hour              ,
  298.  
  299.         minute
  300.  
  301.     ;
  302.        
  303.     gettime ( hour , minute ) ;
  304.  
  305.     format ( string , sizeof string , "%s%d %s%d" , ( hour < 10 ) ? ( "0" ) : ( "" ) , hour , ( minute < 10 ) ? ( "0" ) : ( "" ) , minute ) ;
  306.  
  307.     TextDrawSetString ( ClockTextdraw [ 7 ] , string ) ;
  308.    
  309.     if ( hour == 12 || hour == 13  || hour == 14 || hour == 15 || hour == 16 || hour == 17 || hour == 18 || hour == 19 || hour == 21 )
  310.    
  311.     {
  312.    
  313.         format ( string , sizeof string , " %s%d %s%d" , ( hour < 10 ) ? ( "0" ) : ( "" ) , hour , ( minute < 10 ) ? ( "0" ) : ( "" ) , minute ) ;
  314.  
  315.         TextDrawSetString ( ClockTextdraw [ 7 ] , string ) ;
  316.    
  317.     }
  318.        
  319. }
  320.  
  321. //______________________________________________________________________________
  322.  
  323. CMD:clock( playerid , params [ ] )
  324.  
  325. {
  326.  
  327.     #define SPD  ShowPlayerDialog
  328.  
  329.     SPD ( playerid , 0 , DIALOG_STYLE_LIST , ""W"Clock" , " "W"Clock \t \t \t ["G"ON"W"/"R"OFF"W"] \n "W"Change your time \t ["R"NOT AVAILABLE"W"]" , "O.K" , "Cancel" ) ;
  330.  
  331.     return ( 1 ) ;
  332.  
  333. }
  334.  
  335. //______________________________________________________________________________
  336.  
  337. public OnDialogResponse ( playerid , dialogid , response , listitem , inputtext [ ] )
  338.  
  339. {
  340.  
  341.    if ( dialogid == 0 )
  342.    
  343.    {
  344.    
  345.        if ( response )
  346.        
  347.        {
  348.  
  349.             if ( listitem == 0 )
  350.            
  351.            {
  352.            
  353.                 SPD ( playerid , 1 , DIALOG_STYLE_MSGBOX , " " , " " , "ON" , "OFF" ) ;
  354.            
  355.            }
  356.  
  357.        }
  358.        
  359.        return ( 1 ) ;
  360.        
  361.    }
  362.  
  363.    if ( dialogid == 1 )
  364.  
  365.    {
  366.  
  367.        if ( response )
  368.  
  369.        {
  370.        
  371.            if ( IsActive [ playerid ] == false )
  372.            
  373.            {
  374.        
  375.                 IsActive [ playerid ] = true ;
  376.        
  377.                 TextDrawShowForPlayer ( playerid , ClockTextdraw [ 7 ] ) ;
  378.            
  379.                 TextDrawShowForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  380.                
  381.                 StartClock [ playerid ] = SetTimerEx ( "ActiveClock" , 350 , 0 , "i" , playerid ) ;
  382.  
  383.             }
  384.  
  385.        }
  386.        
  387.        else
  388.        
  389.        {
  390.  
  391.            if ( IsActive [ playerid ] == true )
  392.  
  393.            {
  394.            
  395.                IsActive [ playerid ] = false ;
  396.                
  397.                 KillTimer ( StartClock [ playerid ] ) ;
  398.  
  399.                 KillTimer ( StopClock  [ playerid ] ) ;
  400.        
  401.                 TextDrawHideForPlayer ( playerid , ClockTextdraw [ 7 ] ) ;
  402.                
  403.                 TextDrawHideForPlayer ( playerid , ClockTextdraw [ 6 ] ) ;
  404.  
  405.             }
  406.  
  407.        }
  408.  
  409.        return ( 1 ) ;
  410.  
  411.    }
  412.  
  413.    return ( 0 ) ;
  414.  
  415. }
  416.  
  417. //______________________________________________________________________________
Advertisement
Add Comment
Please, Sign In to add comment