Guest User

Medkit by pWesley

a guest
Apr 10th, 2017
409
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <streamer>
  4.  
  5. #define MAX_MEDKITS  (100)
  6.  
  7. new mcount;
  8.  
  9. enum MB_INFO
  10. {
  11.     medboxID[2],
  12.     Float:medboxPosX,
  13.     Float:medboxPosY,
  14.     Float:medboxPosZ,
  15.     medboxCharge,
  16.     bool:medboxCreated
  17. };
  18. new MedBoxInfo[MAX_MEDKITS][MB_INFO];
  19.  
  20. CreateMedicBox(playerid)
  21. {
  22.     new Float:X, Float:Y, Float:Z;
  23.     GetPlayerPos(playerid, X, Y, Z);
  24.  
  25.     MedBoxInfo[mcount][medboxPosX] = X + 3;
  26.     MedBoxInfo[mcount][medboxPosY] = Y;
  27.     MedBoxInfo[mcount][medboxPosZ] = Z - 1;
  28.     MedBoxInfo[mcount][medboxCharge] = 25;
  29.     MedBoxInfo[mcount][medboxCreated] = true;
  30.  
  31.     MedBoxInfo[mcount][medboxID][0] = CreateDynamicObject(11736, MedBoxInfo[mcount][medboxPosX], MedBoxInfo[mcount][medboxPosY], MedBoxInfo[mcount][medboxPosZ], 0.0, 0.0, 0.0);
  32.     MedBoxInfo[mcount][medboxID][1] = CreateDynamicObject(19606,  MedBoxInfo[mcount][medboxPosX], MedBoxInfo[mcount][medboxPosY], MedBoxInfo[mcount][medboxPosZ] - 1.5, 0.0, 0.0, 0.0);
  33.     mcount++;
  34.     return 1;
  35. }
  36.  
  37. DestroyMedicBox(medbox)
  38. {
  39.     MedBoxInfo[medbox][medboxPosX] = 0;
  40.     MedBoxInfo[medbox][medboxPosY] = 0;
  41.     MedBoxInfo[medbox][medboxPosZ] = 0;
  42.     MedBoxInfo[medbox][medboxCharge] = 0;
  43.     MedBoxInfo[medbox][medboxCreated] = false;
  44.  
  45.     DestroyDynamicObject(MedBoxInfo[medbox][medboxID][0]);
  46.     DestroyDynamicObject(MedBoxInfo[medbox][medboxID][1]);
  47.     return 1;
  48. }
  49.  
  50. forward CheckMedicBox(playerid);
  51. public CheckMedicBox(playerid)
  52. {
  53.     new Float:gArmour, Float:gHealth, Float:Result;
  54.     GetPlayerArmour(playerid, gArmour);
  55.     GetPlayerHealth(playerid, gHealth);
  56.     Result = gArmour + gHealth;
  57.     for(new i; i < sizeof(MedBoxInfo); ++i)
  58.     {
  59.         if(IsPlayerInRangeOfPoint(playerid, 0.5, MedBoxInfo[i][medboxPosX], MedBoxInfo[i][medboxPosY], MedBoxInfo[i][medboxPosZ]))
  60.         {
  61.             if(MedBoxInfo[i][medboxCreated])
  62.             {
  63.                 if(Result == 200.0)
  64.                     return 1;
  65.  
  66.                 PlayerPlaySound(playerid, 45400, 0.0, 0.0, 0.0);
  67.                
  68.                 if(gArmour < 100 && gHealth == 100)
  69.                     SetPlayerArmour(playerid, gArmour + 20.0);
  70.                 if(gHealth < 100)
  71.                     SetPlayerHealth(playerid, gHealth + 20.0);
  72.                
  73.                 if(!MedBoxInfo[i][medboxCharge])
  74.                     return DestroyMedicBox(i);
  75.                    
  76.                 MedBoxInfo[i][medboxCharge]--;
  77.             }
  78.         }
  79.     }
  80.     return 1;
  81. }
  82.  
  83. forward ServerUpdate();
  84. public ServerUpdate()
  85. {
  86.     for(new i; i < MAX_PLAYERS; ++i)
  87.         CheckMedicBox(i);
  88.     return 1;
  89. }
  90.  
  91. main()
  92. {
  93.     return 1;
  94. }
  95.  
  96. public OnGameModeInit()
  97. {
  98.     SetTimer("ServerUpdate", 1000, true);
  99.     return 1;
  100. }
  101.  
  102. public OnGameModeExit()
  103. {
  104.     return 1;
  105. }
  106.  
  107. public OnPlayerConnect(playerid)
  108. {
  109.     return 1;
  110. }
  111.  
  112. public OnPlayerDisconnect(playerid, reason)
  113. {
  114.     return 1;
  115. }
  116.  
  117. CMD:setvida(playerid)
  118. {
  119.     SetPlayerArmour(playerid, 0.0);
  120.     SetPlayerHealth(playerid, 20.0);
  121.     return 1;
  122. }
  123.  
  124. CMD:medkit(playerid)
  125. {
  126.     CreateMedicBox(playerid);
  127.     return 1;
  128. }
RAW Paste Data