Advertisement
Guest User

Krx17 (Gurvinder Singh)

a guest
Feb 16th, 2011
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.87 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #if defined MAX_PLAYERS
  4.     #undef MAX_PLAYERS
  5.     #define MAX_PLAYERS 50 //Change 50 to the max slots your server has.
  6. #endif
  7.  
  8. enum pInfo
  9. {
  10.     Float:lHP,
  11.     bool:Wounded,
  12.     SecondTick
  13. }
  14. new PlayerInfo[MAX_PLAYERS][pInfo];
  15. new Text:BloodScreen;
  16.  
  17. forward HealthCheck();
  18.  
  19. public OnFilterScriptInit()
  20. {
  21.     print("\n [     Wounds System by Krx17 Loaded     ]");
  22.  
  23.     LoadBloodScreen();
  24.     SetupPlayerVariables();
  25.     SetTimer("HealthCheck", 1000, 1);
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     UnloadBloodScreen();
  32.     return 1;
  33. }
  34.  
  35. public OnPlayerConnect(playerid)
  36. {
  37.     ResetPlayerVariable(playerid);
  38. }
  39.  
  40. stock LoadBloodScreen()
  41. {
  42.     BloodScreen = TextDrawCreate(0.0, 1.0, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~");
  43.     TextDrawBackgroundColor(BloodScreen, 0x000000FF);
  44.     TextDrawFont(BloodScreen, 1);
  45.     TextDrawLetterSize(BloodScreen, 1.24, 5.0);
  46.     TextDrawColor(BloodScreen, 0xFFFFFFFF);
  47.     TextDrawSetOutline(BloodScreen, 0);
  48.     TextDrawSetProportional(BloodScreen, true);
  49.     TextDrawSetShadow(BloodScreen, 1);
  50.     TextDrawUseBox(BloodScreen, true);
  51.     TextDrawBoxColor(BloodScreen, 0xFF000044);
  52.     TextDrawTextSize(BloodScreen, 642.0, 0.0);
  53. }
  54.  
  55. stock UnloadBloodScreen()
  56. {
  57.     TextDrawDestroy(BloodScreen);
  58. }
  59.  
  60. stock SetupPlayerVariables()
  61. {
  62.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  63.     {
  64.         GetPlayerHealth(i, PlayerInfo[i][lHP]);
  65.     }
  66. }
  67.  
  68. stock ResetPlayerVariable(playerid)
  69. {
  70.     PlayerInfo[playerid][lHP] = 100;
  71.     PlayerInfo[playerid][Wounded] = false;
  72.     PlayerInfo[playerid][SecondTick] = 0;
  73. }
  74.  
  75. stock OnPlayerHurt(playerid, Float:damage, Float:newHP)
  76. {
  77.     if(newHP > 0)
  78.     {
  79.         if(damage > 10 && PlayerInfo[playerid][Wounded] == false)
  80.         {
  81.             PlayerInfo[playerid][Wounded] = true;
  82.             SendClientMessage(playerid, 0xFF0000AA, ">> Wounded!");
  83.             PlayerInfo[playerid][SecondTick] = 0;
  84.             CallRemoteFunction("OnPlayerWoundUpdate", "ii", playerid, 1);
  85.         }
  86.     }
  87. }
  88.  
  89. public HealthCheck()
  90. {
  91.     new Float:HP;
  92.     for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i))
  93.     {
  94.         GetPlayerHealth(i, HP);
  95.         if(PlayerInfo[i][lHP] > HP)
  96.         {
  97.             OnPlayerHurt(i, PlayerInfo[i][lHP]-HP, HP);
  98.         }
  99.         if(PlayerInfo[i][Wounded] == true)
  100.         {
  101.             PlayerInfo[i][SecondTick]++;
  102.             if(PlayerInfo[i][SecondTick] % 10 == 0)
  103.             {
  104.                 if(PlayerInfo[i][SecondTick] >= 40)
  105.                 {
  106.                     PlayerInfo[i][Wounded] = false;
  107.                     PlayerInfo[i][SecondTick] = 0;
  108.                     TextDrawHideForPlayer(i, BloodScreen);
  109.                     CallRemoteFunction("OnPlayerWoundUpdate", "ii", i, 0);
  110.                     SendClientMessage(i, 0x00FF00AA, ">> Wounds healed");
  111.                     continue;
  112.                 }
  113.                 TextDrawShowForPlayer(i, BloodScreen);
  114.                 SetPlayerHealth(i, HP-3);
  115.             }
  116.             else if(PlayerInfo[i][SecondTick] % 11 == 0)
  117.             {
  118.                 TextDrawHideForPlayer(i, BloodScreen);
  119.             }
  120.         }
  121.         PlayerInfo[i][lHP] = HP;
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement