Advertisement
garfield

[CODE]: Manutenção agendada

Nov 3rd, 2013
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.36 KB | None | 0 0
  1. /*
  2.  
  3.     Crie um arquivo chamado  "agendargmx.txt" e adicione na seguinte forma:
  4.  
  5.     DIA-MES-ANO: Mensagem
  6.  
  7.     Exemplo:
  8.  
  9.     04-11-2013:Manutenção De segurança
  10. */
  11.  
  12.  
  13. VerifyGMX(); public VerifyGMX(){
  14.  
  15.     static
  16.         File: Arquivo,
  17.         Linha[128],
  18.         Datas[3],
  19.         Data[3],
  20.         Tamanho
  21.        
  22.     ;
  23.    
  24.    
  25.     Arquivo = fopen("agendargmx.txt", io_read);
  26.    
  27.    
  28.     while(fread(Arquivo, Linha)){
  29.    
  30.         Tamanho = strlen(Linha);
  31.        
  32.         if(!strfind(Linha, "\r\n")){
  33.             strdel(Linha, Tamanho-2, Tamanho);
  34.         }
  35.        
  36.         if(!strfind(Linha, "\n")){
  37.             strdel(Linha, Tamanho-1, Tamanho);
  38.         }
  39.  
  40.         static
  41.             tmp_file[13]
  42.         ;
  43.        
  44.         strmid(tmp_file, Linha, 0, strfind(Linha, "-"));
  45.  
  46.         Datas[0] = strval(tmp_file); // DIA
  47.        
  48.         strdel(Linha, 0, strfind(Linha, "-")+1);
  49.  
  50.         strmid(tmp_file, Linha, 0, strfind(Linha, "-"));
  51.  
  52.         Datas[1] = strval(tmp_file); // MES
  53.        
  54.         strdel(Linha, 0, strfind(Linha, "-")+1);
  55.        
  56.         strmid(tmp_file, Linha, 0, strfind(Linha, ":"));
  57.        
  58.         Datas[2] = strval(tmp_file); // ANO
  59.        
  60.         strdel(Linha, 0, strfind(Linha, ":") + 1);
  61.        
  62.         getdate(Data[0], Data[1], Data[2]);
  63.        
  64.         if(Data[0] == Datas[2]){
  65.        
  66.             if(Datas[1] == Data[1]){
  67.  
  68.                 if(Datas[0] == Data[2]){
  69.                
  70.                     SendClientMessageToAll(-1, "Manutenção Agendada, ações");
  71.                     SendClientMessageToAll(-1, Linha);
  72.                 }
  73.             }
  74.         }
  75.     }
  76.     return true;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement