Rhay_Fither

[PAWN][FS] Sistema de Fome

Oct 29th, 2012
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.89 KB | None | 0 0
  1. /**********************************[ INCLUDES ]*********************************/
  2. #include <a_samp>
  3. #define FILTERSCRIPT
  4. #include <sscanf>
  5. #include <zcmd>
  6. #include <progress>
  7. #include <DOF2>
  8. /**********************************[ OUTROS ]***********************************/
  9. #define tSpeed(%0) %0*500 // Muito rápido
  10. #define tSegundos(%0) %0*1000 // Segundos
  11. #define tMinutos(%0) %0*60000 // Minutos
  12. #define SendClientMessageEx(%0,%1,%2,%3); format(StringRhay, sizeof StringRhay, %2, %3); SendClientMessage(%0, %1, StringRhay);
  13. #define VerificarConexao(%0,%1); if(!IsPlayerConnected(%0)) return SendClientMessage(%1, COLOR_ERRO, "| ERRO | Player não connectado!");
  14. #define VerificarAdmin(%0,%1); if(!IsPlayerAdmin(%0)) return SendClientMessage(%1, COLOR_ERRO, "| ERRO | Você não tem autorização");
  15. /********************************[ MODIFICAÇÕES ]*******************************/
  16. #define     TEMPO_AUMENTAR_FOME     5 //Em minutos!
  17. #define  DINHEIRO_PERDIDO_AO_MORRER 500 //Quanto dinheiro o player irá perder ao morrer de fome!
  18. /***********************************[ NEW's ]***********************************/
  19. new Bar:BarraFome[MAX_PLAYERS], Fome[MAX_PLAYERS], StringRhay[128], bool:MorreuFome[MAX_PLAYERS];
  20. /**********************************[ CORES's ]**********************************/
  21. #define     COLOR_INFO    0x8470FFFF
  22. #define     COLOR_ERRO    0xFF3030FF
  23. /************************************[ FIM ]************************************/
  24.  
  25. public OnFilterScriptInit()
  26. {
  27.     print("\n|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|");
  28.     print("| [FS] Sistema de Fome - v1.0 |");
  29.     print("|       By: Rhay_Fither       |");
  30.     print("|     LIGADO COM SUCESSO!     |");
  31.     print("|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|\n");
  32.     return 1;
  33. }
  34.  
  35. public OnFilterScriptExit()
  36. {
  37.     DOF2_Exit();
  38.     return 1;
  39. }
  40.  
  41. public OnPlayerConnect(playerid)
  42. {
  43.     new rArquivo[40];
  44.     BarraFome[playerid] = CreateProgressBar(549.00, 59.00, 55.50, 2.50, 0x8470FFFF, 100.0);
  45.     SetTimerEx("AumentarFome", tMinutos(TEMPO_AUMENTAR_FOME), true, "i", playerid);
  46.     SetTimerEx("AtualizarFome", tSegundos(1), true, "i");
  47.     format(rArquivo, sizeof(rArquivo), "FomeSystem/%s.ini", rPlayerName(playerid)); //Formatamos o arquivo de acordo com o nome do player (Contas/NOME)
  48.     Fome[playerid] = DOF2_GetInt(rArquivo, "Fome");
  49.     HideProgressBarForPlayer(playerid, BarraFome[playerid]);
  50.     return 1;
  51. }
  52.  
  53. public OnPlayerDisconnect(playerid, reason)
  54. {
  55.     HideProgressBarForPlayer(playerid, BarraFome[playerid]);
  56.     new rArquivo[40];
  57.     format(rArquivo, sizeof(rArquivo), "FomeSystem/%s.ini", rPlayerName(playerid));
  58.     if(DOF2_FileExists(rArquivo))
  59.     {
  60.         DOF2_SetInt(rArquivo, "Fome", Fome[playerid]);
  61.     }
  62.     else
  63.     {
  64.         DOF2_CreateFile(rArquivo);
  65.         DOF2_SetInt(rArquivo, "Fome", Fome[playerid]);
  66.     }
  67.     return 1;
  68. }
  69.  
  70. public OnPlayerSpawn(playerid)
  71. {
  72.     ShowProgressBarForPlayer(playerid, BarraFome[playerid]);
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerDeath(playerid, killerid, reason)
  77. {
  78.     if(MorreuFome[playerid] == true)
  79.     {
  80.         SetTimerEx("ResetarFome", tSpeed(1), false, "i", playerid);
  81.         MorreuFome[playerid] = false;
  82.     }
  83.     return 1;
  84. }
  85.  
  86. CMD:setarfome(playerid, params[])
  87. {
  88.     new rID, rFome;
  89.     VerificarAdmin(playerid, playerid);
  90.     if(sscanf(params, "ud", rID, rFome)) return SendClientMessage(playerid, COLOR_ERRO, "| ERRO | Use: /setarfome [ID] [FOME]");
  91.     VerificarConexao(rID, playerid);
  92.     Fome[rID] = rFome;
  93.     SendClientMessageEx(rID, COLOR_INFO, "| INFO | O Admin %s setou sua fome para %d.",rPlayerName(playerid), rFome);
  94.     SendClientMessageEx(playerid, 0x7FFF00FF, "| INFO | Fome do player %s setada para %d com sucesso.", rPlayerName(playerid), rFome);
  95.     return 1;
  96. }
  97.  
  98. CMD:comer(playerid)
  99. {
  100.     Fome[playerid] = 0;
  101.     GivePlayerMoney(playerid, -50);
  102.     return 1;
  103. }
  104.  
  105. forward AumentarFome(playerid);
  106. public AumentarFome(playerid)
  107. {
  108.     Fome[playerid] += 5;
  109.     SetProgressBarValue(BarraFome[playerid], Fome[playerid]);
  110.     UpdateProgressBar(BarraFome[playerid], playerid);
  111.    
  112.     if(Fome[playerid] == 95)
  113.     {
  114.         SendClientMessageEx(playerid, COLOR_INFO, "| INFO | %s, você está com muita fome, se não comer, morrerá!", rPlayerName(playerid));
  115.     }
  116.     return 1;
  117. }
  118.  
  119. forward AtualizarFome(playerid);
  120. public AtualizarFome(playerid)
  121. {
  122.     SetProgressBarValue(BarraFome[playerid], Fome[playerid]);
  123.     UpdateProgressBar(BarraFome[playerid], playerid);
  124.  
  125.     if(Fome[playerid] >= 100)
  126.     {
  127.         MorreuFome[playerid] = true;
  128.         HideProgressBarForPlayer(playerid, BarraFome[playerid]);
  129.         SetPlayerHealth(playerid, 0);
  130.         GivePlayerMoney(playerid, -DINHEIRO_PERDIDO_AO_MORRER);
  131.         SendClientMessageEx(playerid, COLOR_INFO, "| INFO | Você morreu de fome e por isso perdeu {00FF00}R$%d{8470FF}!", DINHEIRO_PERDIDO_AO_MORRER);
  132.     }
  133.     return 1;
  134. }
  135.  
  136. forward ResetarFome(playerid);
  137. public ResetarFome(playerid)
  138. {
  139.     Fome[playerid] = 0;
  140.     return 1;
  141. }
  142.  
  143. stock rPlayerName(playerid)
  144. {
  145.     new NomeDaStock[MAX_PLAYER_NAME];
  146.     GetPlayerName(playerid, NomeDaStock, MAX_PLAYER_NAME);
  147.     return NomeDaStock;
  148. }
Advertisement
Add Comment
Please, Sign In to add comment