Advertisement
Eduardo_AC

[FS] Despertador

Jul 7th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.32 KB | None | 0 0
  1. /**********************************************
  2. CRÉDITOS:
  3. include a_samp by #SA:MP TEAM
  4. include zcmd by #ZeeX
  5. include sscanf2 by #Y_Less
  6. TextDraw editor by #iPLEOMAX
  7. Script by F1N4L
  8. **********************************************/
  9.  
  10. #include <a_samp>
  11. #include <zcmd>
  12. #include <sscanf2>
  13.  
  14. //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXTDRAW_DATA_HORA_PLAYERS=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  15. new Text:HORA[2];
  16. new PlayerText:DESP[2][MAX_PLAYERS];
  17.  
  18. new
  19.     P_TIME[3],
  20.     D_TIME[3]
  21. ;
  22.  
  23. new DESPERTADOR[MAX_PLAYERS];
  24. new RELOGIO[MAX_PLAYERS];
  25.  
  26. //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXTDRAW_DATA_HORA_PLAYERS=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  27.  
  28. //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXTDRAW_DATE_TIME_PLAYERS=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  29. stock DateTimePlayers_TextDraw(playerid)
  30. {
  31.     HORA[0] = TextDrawCreate(485.675201, 0.083303, "|HORA|");
  32.     TextDrawLetterSize(HORA[0], 0.350000, 1.001667);
  33.     TextDrawAlignment(HORA[0], 1);
  34.     TextDrawColor(HORA[0], -16776961);
  35.     TextDrawSetOutline(HORA[0], 0);
  36.     TextDrawBackgroundColor(HORA[0], 255);
  37.     TextDrawFont(HORA[0], 2);
  38.     TextDrawSetProportional(HORA[0], 1);
  39.     TextDrawSetShadow(HORA[0], 0);
  40.  
  41.     HORA[1] = TextDrawCreate(481.228942, 7.149960, "00:00:00");
  42.     TextDrawLetterSize(HORA[1], 0.350000, 1.521666);
  43.     TextDrawAlignment(HORA[1], 1);
  44.     TextDrawColor(HORA[1], -16776961);
  45.     TextDrawSetOutline(HORA[1], 0);
  46.     TextDrawBackgroundColor(HORA[1], 255);
  47.     TextDrawFont(HORA[1], 2);
  48.     TextDrawSetProportional(HORA[1], 1);
  49.     TextDrawSetShadow(HORA[1], 0);
  50.    
  51.     DESP[playerid][2] = CreatePlayerTextDraw(playerid, 183.176528, 138.083312, "DESPERTADOR");
  52.     PlayerTextDrawLetterSize(playerid, DESP[playerid][2], 0.960940, 6.727499);
  53.     PlayerTextDrawAlignment(playerid, DESP[playerid][2], 1);
  54.     PlayerTextDrawColor(playerid, DESP[playerid][2], 65535);
  55.     PlayerTextDrawSetShadow(playerid, DESP[playerid][2], 0);
  56.     PlayerTextDrawSetOutline(playerid, DESP[playerid][2], 0);
  57.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][2], 255);
  58.     PlayerTextDrawFont(playerid, DESP[playerid][2], 2);
  59.     PlayerTextDrawSetProportional(playerid, DESP[playerid][2], 1);
  60.     PlayerTextDrawSetShadow(playerid, DESP[playerid][2], 0);
  61.  
  62.     DESP[playerid][1] = CreatePlayerTextDraw(playerid, 249.058807, 185.333358, "HORA");
  63.     PlayerTextDrawLetterSize(playerid, DESP[playerid][1], 1.256940, 5.648333);
  64.     PlayerTextDrawAlignment(playerid, DESP[playerid][1], 1);
  65.     PlayerTextDrawColor(playerid, DESP[playerid][1], 65535);
  66.     PlayerTextDrawSetShadow(playerid, DESP[playerid][1], 0);
  67.     PlayerTextDrawSetOutline(playerid, DESP[playerid][1], 0);
  68.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][1], 255);
  69.     PlayerTextDrawFont(playerid, DESP[playerid][1], 2);
  70.     PlayerTextDrawSetProportional(playerid, DESP[playerid][1], 1);
  71.     PlayerTextDrawSetShadow(playerid, DESP[playerid][1], 0);
  72.  
  73.     DESP[playerid][0] = CreatePlayerTextDraw(playerid, 322.941101, 149.750030, "_");
  74.     PlayerTextDrawLetterSize(playerid, DESP[playerid][0], 0.415529, 9.585833);
  75.     PlayerTextDrawTextSize(playerid, DESP[playerid][0], 0.000000, 316.000000);
  76.     PlayerTextDrawAlignment(playerid, DESP[playerid][0], 2);
  77.     PlayerTextDrawColor(playerid, DESP[playerid][0], -1);
  78.     PlayerTextDrawUseBox(playerid, DESP[playerid][0], 1);
  79.     PlayerTextDrawBoxColor(playerid, DESP[playerid][0], 65298);
  80.     PlayerTextDrawSetShadow(playerid, DESP[playerid][0], 0);
  81.     PlayerTextDrawSetOutline(playerid, DESP[playerid][0], 0);
  82.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][0], 255);
  83.     PlayerTextDrawFont(playerid, DESP[playerid][0], 1);
  84.     PlayerTextDrawSetProportional(playerid, DESP[playerid][0], 1);
  85.     PlayerTextDrawSetShadow(playerid, DESP[playerid][0], 0);
  86.  
  87.     return 1;
  88. }
  89.  
  90. stock PlayeridText(playerid)
  91. {
  92.     DESP[playerid][2] = CreatePlayerTextDraw(playerid, 183.176528, 138.083312, "DESPERTADOR");
  93.     PlayerTextDrawLetterSize(playerid, DESP[playerid][2], 0.960940, 6.727499);
  94.     PlayerTextDrawAlignment(playerid, DESP[playerid][2], 1);
  95.     PlayerTextDrawColor(playerid, DESP[playerid][2], 65535);
  96.     PlayerTextDrawSetShadow(playerid, DESP[playerid][2], 0);
  97.     PlayerTextDrawSetOutline(playerid, DESP[playerid][2], 0);
  98.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][2], 255);
  99.     PlayerTextDrawFont(playerid, DESP[playerid][2], 2);
  100.     PlayerTextDrawSetProportional(playerid, DESP[playerid][2], 1);
  101.     PlayerTextDrawSetShadow(playerid, DESP[playerid][2], 0);
  102.  
  103.     DESP[playerid][1] = CreatePlayerTextDraw(playerid, 249.058807, 185.333358, " ");
  104.     PlayerTextDrawLetterSize(playerid, DESP[playerid][1], 1.256940, 5.648333);
  105.     PlayerTextDrawAlignment(playerid, DESP[playerid][1], 1);
  106.     PlayerTextDrawColor(playerid, DESP[playerid][1], 65535);
  107.     PlayerTextDrawSetShadow(playerid, DESP[playerid][1], 0);
  108.     PlayerTextDrawSetOutline(playerid, DESP[playerid][1], 0);
  109.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][1], 255);
  110.     PlayerTextDrawFont(playerid, DESP[playerid][1], 2);
  111.     PlayerTextDrawSetProportional(playerid, DESP[playerid][1], 1);
  112.     PlayerTextDrawSetShadow(playerid, DESP[playerid][1], 0);
  113.  
  114.     DESP[playerid][0] = CreatePlayerTextDraw(playerid, 322.941101, 149.750030, "_");
  115.     PlayerTextDrawLetterSize(playerid, DESP[playerid][0], 0.415529, 9.585833);
  116.     PlayerTextDrawTextSize(playerid, DESP[playerid][0], 0.000000, 316.000000);
  117.     PlayerTextDrawAlignment(playerid, DESP[playerid][0], 2);
  118.     PlayerTextDrawColor(playerid, DESP[playerid][0], -1);
  119.     PlayerTextDrawUseBox(playerid, DESP[playerid][0], 1);
  120.     PlayerTextDrawBoxColor(playerid, DESP[playerid][0], 65298);
  121.     PlayerTextDrawSetShadow(playerid, DESP[playerid][0], 0);
  122.     PlayerTextDrawSetOutline(playerid, DESP[playerid][0], 0);
  123.     PlayerTextDrawBackgroundColor(playerid, DESP[playerid][0], 255);
  124.     PlayerTextDrawFont(playerid, DESP[playerid][0], 1);
  125.     PlayerTextDrawSetProportional(playerid, DESP[playerid][0], 1);
  126.     PlayerTextDrawSetShadow(playerid, DESP[playerid][0], 0);
  127.     return 1;
  128. }
  129. //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXTDRAW_DATE_TIME_PLAYERS=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  130.  
  131. public OnPlayerConnect(playerid)
  132. {
  133.     SetPVarInt(playerid,"Despertador",-1);
  134.     return 1;
  135. }
  136.  
  137. public OnPlayerSpawn(playerid)
  138. {
  139.     //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXT_DRAW_SHOW_SERVER=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  140.     DateTimePlayers_TextDraw(playerid);
  141.    
  142.     TextDrawShowForPlayer(playerid, HORA[0]);
  143.     TextDrawShowForPlayer(playerid, HORA[1]);
  144.    
  145.     RELOGIO[playerid] = SetTimerEx("TimePlayers_TextDraw", 1000, true, "i", playerid);
  146.    
  147.     SendClientMessage(playerid, -1, "Sistema de Despertador By F1N4L");
  148.     //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXT_DRAW_SHOW_SERVER=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  149.     return 1;
  150. }
  151.  
  152. public OnPlayerDisconnect(playerid, reason)
  153. {
  154.     //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXT_DRAW_HIDE_SERVER=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  155.     TextDrawHideForPlayer(playerid, HORA[0]);
  156.     TextDrawHideForPlayer(playerid, HORA[1]);
  157.    
  158.     PlayerTextDrawHide(playerid, DESP[playerid][0]);
  159.     PlayerTextDrawHide(playerid, DESP[playerid][1]);
  160.     PlayerTextDrawHide(playerid, DESP[playerid][2]);
  161.    
  162.     KillTimer(DESPERTADOR[playerid]);
  163.     KillTimer(RELOGIO[playerid]);
  164.     //=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=TEXT_DRAW_HIDE_SERVER=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=
  165.     return 1;
  166.  
  167. }
  168.  
  169. forward TimePlayers_TextDraw(playerid);
  170. public TimePlayers_TextDraw(playerid)
  171. {
  172.     new string[10];
  173.    
  174.     gettime(P_TIME[0], P_TIME[1], P_TIME[2]);
  175.    
  176.     format(string, 128, "%02d:%02d:%02d", P_TIME[0], P_TIME[1], P_TIME[2]);
  177.     TextDrawSetString(HORA[1], string);
  178.    
  179.     return 1;
  180. }
  181.  
  182. CMD:desp(playerid, params[])
  183. {
  184.     new string[90];
  185.    
  186.     if(GetPVarInt(playerid,"Despertador") == 0)
  187.     {
  188.         if(sscanf(params, "iii", D_TIME[0], D_TIME[1], D_TIME[2])) return SendClientMessage(playerid, -1, "USO: /desp [Hora] [Min] [Seg]");
  189.         if(D_TIME[0] < 0 || D_TIME[0] > 23) return SendClientMessage(playerid, -1, "ERRO: A Hora deve ser entre 0 e 23.");
  190.         if(D_TIME[0] < P_TIME[0]) return SendClientMessage(playerid, -1, "ERRO: A Hora deve ser maior que as Horas atuais.");
  191.         if(D_TIME[1] < 0 || D_TIME[1] > 59) return SendClientMessage(playerid, -1, "ERRO: Os Minutos devem ser entre 0 e 59.");
  192.         if(D_TIME[1] < P_TIME[1]) return SendClientMessage(playerid, -1, "ERRO: O Minuto deve ser maior que os Minutos atuais");
  193.         if(D_TIME[2] < 0 || D_TIME[2] > 59) return SendClientMessage(playerid, -1, "ERRO: Os Segundos devem ser entre 0 e 59.");
  194.         if(D_TIME[2] <= P_TIME[2]+5) return SendClientMessage(playerid, -1, "ERRO: O Segundo deve ser maior que os Segundos atuais.");
  195.        
  196.         format(string, sizeof(string), "Atualmente são: %02d:%02d:%02d", P_TIME[0], P_TIME[1], P_TIME[2]);
  197.         SendClientMessage(playerid, -1, string);
  198.         format(string, sizeof(string), "Horário Programado para Despertar: %02d:%02d", D_TIME[0], D_TIME[1]);
  199.         SendClientMessage(playerid, -1, string);
  200.         format(string, sizeof(string), "Ainda restam: %02d horas %02d minutos %02d segundos", D_TIME[0]-P_TIME[0], D_TIME[1]-P_TIME[1], D_TIME[2]-P_TIME[2]);
  201.         SendClientMessage(playerid, -1, string);
  202.        
  203.         DESPERTADOR[playerid] = SetTimerEx("DESPERTADOR_Update", 1000, true, "i", playerid);
  204.        
  205.         SetPVarInt(playerid,"Despertador",1);
  206.     }else{
  207.         if(GetPVarInt(playerid,"Despertador") == -1)
  208.         {
  209.                 SendClientMessage(playerid, -1, "Você ainda não iniciou o despertador, Digite: /desp [hora] [min] [seg]");
  210.                 SetPVarInt(playerid,"Despertador",0);
  211.         }
  212.         else if(GetPVarInt(playerid,"Despertador") == 1)
  213.         {
  214.             format(string, sizeof(string), "Você já Ativou o Despertador às: %02d:%02d:%02d", D_TIME[0], D_TIME[1], D_TIME[2]);
  215.             SendClientMessage(playerid, -1, string);
  216.             SendClientMessage(playerid, -1, "Para iniciar um novo despertador, Digite: /offdesp");
  217.         }
  218.     }
  219.    
  220.     if(GetPVarInt(playerid,"Despertador") == -1)
  221.     {  
  222.         SendClientMessage(playerid, -1, "Você ainda não iniciou o despertador, Digite: /desp [hora] [min] [seg]");
  223.         SetPVarInt(playerid,"Despertador",-1);
  224.     }
  225.    
  226.     return 1;
  227. }
  228.  
  229. CMD:offdesp(playerid, params[])
  230. {
  231.     new string[80];
  232.    
  233.     if(GetPVarInt(playerid,"Despertador") == 0)
  234.     {
  235.         SendClientMessage(playerid, -1, "Você já desativou o Despertador!");
  236.     }
  237.     else if(GetPVarInt(playerid,"Despertador") == 1)
  238.     {
  239.         format(string, sizeof(string), "Relógio parado às: %02d:%02d:%02d", P_TIME[0], P_TIME[1], P_TIME[2]);
  240.         SendClientMessage(playerid, -1, string);
  241.        
  242.         PlayerTextDrawHide(playerid, DESP[playerid][0]);
  243.         PlayerTextDrawHide(playerid, DESP[playerid][1]);
  244.         PlayerTextDrawHide(playerid, DESP[playerid][2]);
  245.        
  246.         KillTimer(DESPERTADOR[playerid]);
  247.        
  248.         SetPVarInt(playerid,"Despertador",0);
  249.        
  250.         return 1;
  251.     }
  252.     else if(GetPVarInt(playerid,"Despertador") == -1)
  253.     {
  254.         SendClientMessage(playerid, -1, "Você ainda não iniciou o Despertador, Digite: /desp [hora] [min] [seg]");
  255.     }
  256.  
  257.     return 1;
  258. }
  259.  
  260. forward DESPERTADOR_Update(playerid);
  261. public DESPERTADOR_Update(playerid)
  262. {
  263.     new string[50], string2[16];
  264.    
  265.     if(GetPVarInt(playerid,"Despertador") == 1)
  266.     {
  267.         gettime(P_TIME[0], P_TIME[1], P_TIME[2]);
  268.        
  269.         if(D_TIME[0] == P_TIME[0] && D_TIME[1] == P_TIME[1] && D_TIME[2] == P_TIME[2])
  270.         {
  271.             format(string, sizeof(string), "DESPERTADOR: %02d:%02d:%02d", D_TIME[0], D_TIME[1], D_TIME[2]);
  272.             SendClientMessage(playerid, -1, string);
  273.            
  274.             PlayerTextDrawShow(playerid, DESP[playerid][0]);
  275.             PlayerTextDrawShow(playerid, DESP[playerid][1]);
  276.             PlayerTextDrawShow(playerid, DESP[playerid][2]);
  277.             format(string2, 128, "%02d:%02d:%02d", P_TIME[0], P_TIME[1], P_TIME[2]);
  278.             PlayerTextDrawSetString(playerid, DESP[playerid][1], string2);
  279.         }
  280.     }
  281.    
  282.     return 1;
  283. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement