Advertisement
IlanZiin

[FS] Sistema de MedKit 1.0v

Oct 22nd, 2017
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.86 KB | None | 0 0
  1. /* ***********************************************************************************************************
  2.  
  3.                                     FilterScript criado por: IlanZ
  4.  
  5.                                     Skype: ilan.silva11
  6.  
  7.                                     (Não tire os créditos)                                    
  8.  
  9.    ***********************************************************************************************************
  10. */
  11. #include <a_samp>
  12. #include <zcmd>
  13.  
  14. #define MAX_MEDKITS         (10)
  15. #define DURABILIDADE_MEDKIT (10)
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     print("\n--------------------------------------");
  20.     print(" FilterScript MedKit 1.0v Carregado. By: IlanZ");
  21.     print("--------------------------------------\n");
  22.  
  23.     SetTimer("MedKit", 1000, true);
  24.     print("Iniciado");
  25.     return 1;
  26. }                  
  27.  
  28. enum MedKitEnum
  29. {
  30.     mID,
  31.     mDono[MAX_PLAYER_NAME],
  32.     Float:mX,
  33.     Float:mY,
  34.     Float:mZ,
  35.     mDurabilidade, // default: 10
  36.     mObjetos[2],
  37.     bool:mAtivo
  38. };
  39.  
  40. new MedKitDados[MAX_MEDKITS][MedKitEnum];
  41. new bool:MedKitZ[MAX_PLAYERS], MedKitZID[MAX_PLAYERS];
  42.  
  43. public OnPlayerConnect(playerid)
  44. {
  45.     SpawnPlayer(playerid);
  46.     return 1;
  47. }
  48. public OnPlayerDisconnect(playerid, reason)
  49. {
  50.     DestruirMedKit(MedKitZID[playerid]);
  51.     return 1;
  52. }
  53.  
  54. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  55. {
  56.     if(newkeys == KEY_SECONDARY_ATTACK)
  57.     {
  58.         cmd_infomedkit(playerid);
  59.     }
  60.     return 1;
  61. }
  62.  
  63. forward MedKit();
  64. public MedKit()
  65. {
  66.     for(new i; i < MAX_PLAYERS; ++i)
  67.     {
  68.         DetectarMedKit(i);
  69.     }
  70.     return 1;
  71. }
  72.  
  73. DetectarMedKit(playerid)
  74. {
  75.     new Float:Vida, Float:Colete;
  76.     GetPlayerHealth(playerid, Vida);
  77.     GetPlayerArmour(playerid, Colete);
  78.     for(new i; i < MAX_MEDKITS; i++)
  79.     {
  80.         if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitDados[i][mX], MedKitDados[i][mY], MedKitDados[i][mZ]) && MedKitDados[i][mAtivo])
  81.         {
  82.             if(Vida >= 100 && Colete >= 100) continue;
  83.             else if(Vida < 100)
  84.             {
  85.                 SetPlayerHealth(playerid, (Vida+7));
  86.                 PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
  87.                 MedKitDados[i][mDurabilidade]--;
  88.             }
  89.             else if(Vida >= 100)
  90.             {
  91.                 SetPlayerArmour(playerid, (Colete+7));
  92.                 PlayerPlaySound(playerid, 5202, 0.0, 0.0, 0.0);
  93.                 MedKitDados[i][mDurabilidade]--;
  94.             }
  95.  
  96.             if(MedKitDados[i][mDurabilidade] == 0)
  97.             {
  98.                 DestruirMedKit(MedKitDados[i][mID]);
  99.                 MedKitZ[playerid] = false;
  100.                 PlayerPlaySound(playerid, 6402, 0.0, 0.0, 0.0);
  101.                 SendClientMessage(playerid, -1, "Medkit quebrou!");
  102.             }
  103.         }
  104.     }
  105.     return 1;
  106. }
  107.  
  108. CMD:medkit(playerid)
  109. {
  110.     new Float:X, Float:Y, Float:Z, medkitid;
  111.     if(MedKitZ[playerid])
  112.         return SendClientMessage(playerid, -1, "Você so pode criar um medkit");
  113.     if(GetTotalMedKits() > MAX_MEDKITS)
  114.         return SendClientMessage(playerid, -1, "Você não pode criar agora, atingiu o limite");
  115.     GetPlayerPos(playerid,X,Y,Z);
  116.     MedKitDados[medkitid][mID] = playerid;
  117.     medkitid = MedKitDados[medkitid][mID];
  118.  
  119.     MedKitDados[medkitid][mAtivo] = true;
  120.     MedKitDados[medkitid][mX] = X;
  121.     MedKitDados[medkitid][mY] = Y;
  122.     MedKitDados[medkitid][mZ] = Z;
  123.     MedKitDados[medkitid][mDurabilidade] = DURABILIDADE_MEDKIT; // default
  124.     MedKitDados[medkitid][mObjetos][0] = CreateObject(19605, X, Y, Z-2.0, 0, 0, 0);
  125.     MedKitDados[medkitid][mObjetos][1] = CreatePickup(1240, 1, X, Y, Z);
  126.     MedKitZ[playerid] = true;
  127.     MedKitZID[playerid] = medkitid;
  128.     strcat(MedKitDados[medkitid][mDono], PlayerName(playerid), MAX_PLAYER_NAME);
  129.  
  130.     SendClientMessage(playerid, -1, "Medkit criado");
  131.     return 1;
  132. }
  133.  
  134. CMD:infomedkit(playerid)
  135. {
  136.     for(new i; i < MAX_MEDKITS; i++)
  137.     {
  138.         if(IsPlayerInRangeOfPoint(playerid, 1.0, MedKitDados[i][mX], MedKitDados[i][mY], MedKitDados[i][mZ]) && MedKitDados[i][mAtivo])
  139.         {
  140.             new str[138];
  141.             format(str, sizeof(str), "Medkit ID: %d\nMedKit X: %.2f\nMedKit Y: %.2f\nMedKit Z: %.2f\nMedKit durabilidade: (%d/10)\nMedKit dono: %s",
  142.             MedKitDados[i][mID],
  143.             MedKitDados[i][mX],
  144.             MedKitDados[i][mY],
  145.             MedKitDados[i][mZ],
  146.             MedKitDados[i][mDurabilidade],
  147.             MedKitDados[i][mDono]);
  148.             ShowPlayerDialog(playerid, 666, DIALOG_STYLE_MSGBOX, "Informaçoes do MedKit", str, "Sair", "");
  149.         }
  150.     }
  151.     return 1;
  152. }
  153.  
  154. CMD:destruirmedkit(playerid)
  155. {
  156.     MedKitDados[playerid][mID] = -1;
  157.     MedKitDados[playerid][mAtivo] = false;
  158.     MedKitDados[playerid][mDono][0] = EOS;
  159.     DestroyObject(MedKitDados[playerid][mObjetos][0]);
  160.     DestroyPickup(MedKitDados[playerid][mObjetos][1]);
  161.     MedKitZ[playerid] = false;
  162.  
  163.     SendClientMessage(playerid, -1, "Você destruiu seu Medkit");
  164.     return 1;
  165. }
  166.  
  167. DestruirMedKit(medkitid)
  168. {
  169.     MedKitDados[medkitid][mID] = -1;
  170.     MedKitDados[medkitid][mAtivo] = false;
  171.     MedKitDados[medkitid][mDono][0] = EOS;
  172.  
  173.     DestroyObject(MedKitDados[medkitid][mObjetos][0]);
  174.     DestroyPickup(MedKitDados[medkitid][mObjetos][1]);
  175.     return 1;
  176. }
  177.  
  178. GetTotalMedKits()
  179. {
  180.     new total;
  181.     for(new i; i < MAX_MEDKITS; i++)
  182.     {
  183.         if(MedKitDados[i][mAtivo]) total++;    
  184.     }
  185.     return total;
  186. }
  187.  
  188. PlayerName(playerid)
  189. {
  190.     new nome[24];
  191.     GetPlayerName(playerid, nome, sizeof(nome));
  192.     return nome;
  193. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement