Advertisement
garfield

[FS]: Sistema Prender (ZCMD, DOF2, SSCANF).

Apr 5th, 2012
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.68 KB | None | 0 0
  1. // Prender Player Usando Double-O-Files2 & sscanf & zcmd.
  2.  
  3.  
  4. #include <a_samp>
  5. #include <a_zcmd>
  6. #include <sscanf>
  7. #include DOF2
  8.  
  9.  
  10.  
  11.  
  12. new
  13.     pPreso[MAX_PLAYERS],
  14.     Arquivo[60],
  15.     String[128]
  16. ;
  17.  
  18.  
  19.  
  20. public OnFilterScriptInit()
  21. {
  22.     printf("Sistema de prisão: ByScripterDark");
  23.     SetTimer("JailSet", 60000, true);
  24.     return 1;
  25. }
  26.  
  27. JailSet(pid); public JailSet(pid)
  28. {
  29.     for(new i, e = GetMaxPlayers(); i != e; ++i){
  30.         if(IsPlayerConnected(i) && pPreso[i] != 0) {
  31.             if(pPreso[i] == 1){
  32.                 format(Arquivo, sizeof(Arquivo),"%s.jl", GetNick(i));
  33.                 fremove(Arquivo);
  34.                 SpawnPlayer(i);
  35.             }
  36.             pPreso[i]--;
  37.         }
  38.     }
  39. }
  40.  
  41. GetNick(p)
  42. {
  43.     static n[24]; GetPlayerName(p, n, 24);
  44.     return n;
  45. }
  46.  
  47.  
  48. ////////////////////////////////////////////////////////////////////////////////
  49. CMD:prender(playerid, params[])
  50. {
  51.     static pid, time;
  52.     if(sscanf(params,"ui", pid, time) || time < 0)
  53.         return SendClientMessage(playerid, -1, "ERRO: /Prender <id> <tempo(minutos)>");
  54.  
  55.     if(!IsPlayerConnected(playerid))
  56.         return SendClientMessage(playerid, -1, "ERRO: Player Não conectado!");
  57.  
  58.  
  59.     format(Arquivo, sizeof(Arquivo),"%s.jl", GetNick(pid));
  60.     if(!fexist(Arquivo))
  61.     {
  62.         // Cria o arquivo
  63.         DOF2_CreateFile(Arquivo);
  64.  
  65.  
  66.         // Formatar Mensagem
  67.         format(String, sizeof(String),"%s ajustou a prisão de %s, pelo tempo de %d(Min)", GetNick(playerid), GetNick(pid), time);
  68.  
  69.  
  70.         // Salvar no arquivo
  71.         DOF2_SetInt(Arquivo, "Tempo", time);
  72.     }
  73.     else
  74.     {
  75.         // Formata Mensagem
  76.         format(String, sizeof(String),"%s prendeu %s, pelo tempo de %d(Min)", GetNick(playerid), GetNick(pid), time);
  77.  
  78.  
  79.         // Seta no arquivo
  80.         DOF2_SetInt(Arquivo, "Tempo", time);
  81.     }
  82.    
  83.    
  84.     // Mandar a mensagem
  85.     SendClientMessage(playerid, -1, String);
  86.  
  87.     // Bota o tempo para a variavel pPreso
  88.     pPreso[pid] = time;
  89.    
  90.     // Seta o id para a posição(cadeia), retirado do fs do Pedro_Miranda
  91.     SetPlayerPos(pid, -221.059051,1408.984008,27.773437);
  92.     return 1;
  93. }
  94.  
  95.  
  96.  
  97. CMD:soltar(playerid, params[])
  98. {
  99.     static pid[32];
  100.     if(sscanf(params,"s[32]", pid))
  101.         return SendClientMessage(playerid, -1, "ERRO: /Soltar <nick>");
  102.  
  103.  
  104.     format(Arquivo, sizeof(Arquivo),"%s.jl", pid);
  105.     if(fexist(Arquivo)) fremove(Arquivo);
  106.     else
  107.     {
  108.         for(new i, e = GetMaxPlayers(); i != e; ++i){
  109.             if(IsPlayerConnected(i)){
  110.                 pPreso[i] = 0;
  111.                 SpawnPlayer(i);
  112.             }
  113.         }
  114.     }
  115.    
  116.     SendClientMessage(playerid, -1, "Solto");
  117.     return 1;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement