Advertisement
losnato

[FilterScript] Cadeia

Jan 4th, 2012
6,957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.30 KB | None | 0 0
  1. /****************************************************************************
  2.  *                                                                          *
  3.  *                              -- CADEIA --                                *
  4.  *                                                                          *
  5.  *                              (FilterScript)                              *
  6.  *                                                                          *
  7.  *                              -- by Lós --                                *
  8.  *                                                                          *
  9.  *                     Thanks to Shelby by his Sexy Ass.                    *
  10.  ****************************************************************************/
  11.  
  12. //============== [ INCLUDES ]=============//
  13. #include        <       a_samp      >
  14. #include        <       zcmd        >
  15. #include        <       DOF2        >
  16. #include        <       sscanf2     >
  17. #include        <       foreach     >
  18.  
  19. //============== [ CONFIGURAÇÕES ] =============//
  20. #define         COORDENADAS_CADEIA          /*X da cadeia*/, /*Y da cadeia*/, /*Z da cadeia*/
  21. #define         INTERIOR_CADEIA             /*ID DO INTERIOR DA CADEIA*/
  22.  
  23. #define         ARQUIVO                     "Cadeia/%s.ini"
  24.  
  25. //============== [ DEACLARAÇÕES ] =============//
  26. new
  27.     G_PLAYER_PRESO_CADEIA_ADMIN[MAX_PLAYERS],
  28.     G_TEMPO_CADEIA[MAX_PLAYERS],
  29.     G_TEMPO_RESTANTE_CADEIA[MAX_PLAYERS],
  30.     G_TEMPO_DA_CADEIA[MAX_PLAYERS];
  31.  
  32. forward TirarDaCadeia(id);
  33. forward VerificarTempoRestante(id);
  34.  
  35. //============== [ PUBLICS ] ===================//
  36. public OnFilterScriptExit()
  37. {
  38.     DOF2_Exit();
  39.     return 1;
  40. }
  41.  
  42. public OnPlayerDisconnect(playerid)
  43. {
  44.     if(G_PLAYER_PRESO_CADEIA_ADMIN[playerid] == 1) return S_SALVAR_CADEIA(playerid);
  45.     return 1;
  46. }
  47.  
  48. public VerificarTempoRestante(id)
  49. {
  50.     G_TEMPO_RESTANTE_CADEIA[id]--;
  51.     new L_TIMER;
  52.     if(G_TEMPO_RESTANTE_CADEIA[id] == 0) KillTimer(L_TIMER);
  53.     L_TIMER = SetTimerEx("VerificarTempoRestante", 1000, false, "i", id);
  54.     return 1;
  55. }
  56.  
  57.  
  58. public TirarDaCadeia(id)
  59. {
  60.     SpawnPlayer(id);
  61.     S_REMOVER_CADEIA(id);
  62.     G_PLAYER_PRESO_CADEIA_ADMIN[id] = 0;
  63.     G_TEMPO_DA_CADEIA[id] = 0;
  64.     KillTimer(G_TEMPO_CADEIA[id]);
  65.     return 1;
  66. }
  67.  
  68. public OnPlayerSpawn(playerid)
  69. {
  70.     new L_CAMINHO_ARQUIVO[50]; format(L_CAMINHO_ARQUIVO, sizeof(L_CAMINHO_ARQUIVO), ARQUIVO, S_GET_PLAYER_NAME(playerid));
  71.     if(DOF2_FileExists(L_CAMINHO_ARQUIVO))
  72.     {
  73.         SendClientMessage(playerid, -1, "Você estava preso e voltou para prisão!");
  74.         SetPlayerPos(playerid, COORDENADAS_CADEIA);
  75.         SetPlayerInterior(L_ID, INTERIOR_CADEIA);
  76.         G_PLAYER_PRESO_CADEIA_ADMIN[playerid] = 1;
  77.         G_TEMPO_RESTANTE_CADEIA[playerid] = (playerid, DOF2_GetInt(L_CAMINHO_ARQUIVO, "Tempo"));
  78.         G_TEMPO_CADEIA[playerid] = SetTimerEx("TirarDaCadeia", G_TEMPO_RESTANTE_CADEIA[playerid], false, "i", "playerid");
  79.         return 1;
  80.     }
  81.     return 1;
  82. }
  83.  
  84. //============== [ COMANDOS ] ===================//
  85. CMD:cadeia(playerid, params[])
  86. {
  87.     new L_ID, L_TEMPO, L_MOTIVO[60], L_STRING[128];
  88.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Você não é administrador logado na RCON!");
  89.     if(sscanf(params, "uds", L_ID, L_TEMPO, L_MOTIVO)) return SendClientMessage(playerid, -1, "Use: /cadeia {00E5FF}[ID] [Tempo (em minutos)] [Motivo]");
  90.     if(G_PLAYER_PRESO_CADEIA_ADMIN[L_ID] == 1) return SendClientMessage(playerid, -1, "Este player já está preso!");
  91.     SetPlayerPos(L_ID, COORDENADAS_CADEIA);
  92.     SetPlayerInterior(L_ID, INTERIOR_CADEIA);
  93.     G_PLAYER_PRESO_CADEIA_ADMIN[L_ID] = 1;
  94.     format(L_STRING, sizeof(L_STRING), "%s colocou %s na cadeia. Motivo: %s", S_GET_PLAYER_NAME(playerid), S_GET_PLAYER_NAME(L_ID), L_MOTIVO);
  95.     SendClientMessageToAll(-1, L_STRING);
  96.     G_TEMPO_DA_CADEIA[L_ID] = L_TEMPO*60000;
  97.     G_TEMPO_RESTANTE_CADEIA[L_ID] = G_TEMPO_DA_CADEIA[L_ID];
  98.     VerificarTempoRestante(L_ID);
  99.     G_PLAYER_PRESO_CADEIA_ADMIN[playerid] = 1;
  100.     G_TEMPO_CADEIA[L_ID] = SetTimerEx("TirarDaCadeia", G_TEMPO_RESTANTE_CADEIA[L_ID], false, "i", L_ID);
  101.     S_SALVAR_CADEIA(L_ID);
  102.     return 1;
  103. }
  104.  
  105. CMD:soltar(playerid, params[])
  106. {
  107.     new L_ID, L_MOTIVO[60], L_STRING[128];
  108.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Você não é administrador logado na RCON!");
  109.     if(G_PLAYER_PRESO_CADEIA_ADMIN[L_ID] == 0) return SendClientMessage(playerid, -1, "Este player já está solto!");
  110.     if(sscanf(params, "us", L_ID, L_MOTIVO)) return SendClientMessage(playerid, -1, "Use: /soltar {00E5FF}[ID] [Motivo]");
  111.     format(L_STRING, sizeof(L_STRING), "%s retirou %s da cadeia. Motivo: %s", S_GET_PLAYER_NAME(playerid), S_GET_PLAYER_NAME(L_ID), L_MOTIVO);
  112.     SendClientMessageToAll(-1, L_STRING);
  113.     return TirarDaCadeia(L_ID);
  114. }
  115.  
  116. CMD:tempocadeia(playerid)
  117. {
  118.     new L_STRING[128];
  119.     if(G_PLAYER_PRESO_CADEIA_ADMIN[playerid] == 0) return SendClientMessage(playerid, -1, "Você não está preso!");
  120.     format(L_STRING, sizeof(L_STRING), "Você ainda vai ficar preso por %d segundos.", G_TEMPO_RESTANTE_CADEIA[playerid]);
  121.     return SendClientMessageToAll(-1, L_STRING);
  122. }
  123.  
  124. CMD:presos(playerid)
  125. {
  126.     new L_STRING[128];
  127.     foreach(new i : Player)
  128.     {
  129.         if(G_PLAYER_PRESO_CADEIA_ADMIN[i] == 1)
  130.         {
  131.             format(L_STRING, sizeof(L_STRING), "%s. Cadeia: Admin. Tempo: %d segundos.", S_GET_PLAYER_NAME(i), G_TEMPO_RESTANTE_CADEIA[i]);
  132.             SendClientMessageToAll(-1, L_STRING);
  133.         }
  134.     }
  135.     return 1;
  136. }
  137.  
  138. //============== [ STOCKS ] ===================//
  139. stock S_SALVAR_CADEIA(id)
  140. {
  141.     new L_CAMINHO_ARQUIVO[50]; format(L_CAMINHO_ARQUIVO, sizeof(L_CAMINHO_ARQUIVO), ARQUIVO, S_GET_PLAYER_NAME(id));
  142.     if(!DOF2_FileExists(L_CAMINHO_ARQUIVO)) DOF2_CreateFile(L_CAMINHO_ARQUIVO);
  143.     DOF2_SetInt(L_CAMINHO_ARQUIVO, "Tempo", G_TEMPO_RESTANTE_CADEIA[id]);
  144.     return 1;
  145. }
  146.  
  147. stock S_REMOVER_CADEIA(id)
  148. {
  149.     new L_CAMINHO_ARQUIVO[50]; format(L_CAMINHO_ARQUIVO, sizeof(L_CAMINHO_ARQUIVO), ARQUIVO, S_GET_PLAYER_NAME(id));
  150.     if(DOF2_FileExists(L_CAMINHO_ARQUIVO)) return DOF2_RemoveFile(L_CAMINHO_ARQUIVO);
  151.     G_PLAYER_PRESO_CADEIA_ADMIN[id] = 0;
  152.     return 1;
  153. }
  154.  
  155. stock S_GET_PLAYER_NAME(playerid)
  156. {
  157.     new L_N[MAX_PLAYER_NAME]; GetPlayerName(playerid, L_N, MAX_PLAYER_NAME); return L_N;
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement