Advertisement
LeomarMM

Dying Status for SA-MP

Sep 16th, 2012
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.06 KB | None | 0 0
  1. //Dying System for RE5 Fans
  2. //By TreePuncher or Jay_McReary
  3. #include <a_samp>
  4. #define PRESSED(%0) \
  5. (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  6. forward DyingTime(playerid);
  7. new DyingTimer;
  8. new Text:DyingText;
  9. new Text3D:DyingTextWarn[MAX_PLAYERS];
  10. new DyingStated[MAX_PLAYERS];
  11. public OnFilterScriptInit()
  12. {
  13.      DyingText = TextDrawCreate(312.000000, 198.000000, "You Are Dying");
  14.      TextDrawAlignment(DyingText, 2);
  15.      TextDrawBackgroundColor(DyingText, 255);
  16.      TextDrawFont(DyingText, 0);
  17.      TextDrawLetterSize(DyingText, 0.879998, 3.699997);
  18.      TextDrawColor(DyingText, -16776961);
  19.      TextDrawSetOutline(DyingText, 1);
  20.      TextDrawSetProportional(DyingText, 1);
  21.      return 1;
  22. }
  23. public OnPlayerUpdate(playerid)
  24. {
  25.      new Float:Health;
  26.      GetPlayerHealth(playerid, Health);
  27.      if(Health <= 15)
  28.      {
  29.          if(!GetPVarInt(playerid, "DyingVar"))
  30.          {
  31.          DyingStated[playerid] = 1;
  32.          DyingTimer = SetTimer("DyingTime", 5000, true);
  33.          TextDrawShowForPlayer(playerid, DyingText);
  34.          SetPVarInt(playerid, "DyingVar", true);
  35.          DyingTextWarn[playerid] = Create3DTextLabel("DYING!!", 0xFF0002AA, 0, 0, 0, 0, 0, 0);
  36.          Attach3DTextLabelToPlayer(DyingTextWarn[playerid], playerid, 0, 0, 2);
  37.          SendClientMessage(playerid, 0xFF0402AA, "You are dying, repeatedly press FIRE BUTTON in order to survive!");
  38.          ApplyAnimation(playerid, "KNIFE", "KILL_Knife_Ped_Die", 2, 0, 1, 1, 1, 0, 1);
  39.          return 1;
  40.          }
  41.       }
  42.       else
  43.       {
  44.          if(GetPVarInt(playerid, "DyingVar"))
  45.          {
  46.          KillTimer(DyingTimer);
  47.          TextDrawHideForPlayer(playerid, DyingText);
  48.          DeletePVar(playerid, "DyingVar");
  49.          DyingStated[playerid] = 0;
  50.          Delete3DTextLabel(DyingTextWarn[playerid]);
  51.          ClearAnimations(playerid);
  52.          return 1;
  53.          }
  54.       }
  55.      return 0;
  56. }
  57. public DyingTime(playerid)
  58. {
  59.      new Float:ChangeHealth, Float:x, Float:y, Float:z;
  60.      GetPlayerHealth(playerid, ChangeHealth);
  61.      SetPlayerHealth(playerid, ChangeHealth-1);
  62.      GetPlayerPos(playerid, x, y, z);
  63.      PlayerPlaySound(playerid, 1002, x, y, z);
  64.      DyingStated[playerid] = 1;
  65.      return 1;
  66. }
  67. public OnPlayerDeath(playerid, killerid, reason)
  68. {
  69.      if(DyingStated[playerid] == 1)
  70.      {
  71.      new dpName[MAX_PLAYER_NAME], dpstr[128];
  72.      GetPlayerName(playerid, dpName, sizeof(dpName));
  73.      format(dpstr, sizeof(dpstr), "%s [%i] has died while on dying status", dpName, playerid);
  74.      SendClientMessageToAll(0x0000FFAA, dpstr);
  75.      print(dpstr);
  76.      KillTimer(DyingTimer);
  77.      DyingStated[playerid] = 0;
  78.      Delete3DTextLabel(DyingTextWarn[playerid]);
  79.      ClearAnimations(playerid);
  80.      return 1;
  81.      }
  82.      return 1;
  83. }
  84. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  85. {
  86.      if(DyingStated[playerid] == 1)
  87.      {
  88.          if(PRESSED(KEY_FIRE))
  89.          {
  90.          new Float:RecoverHealth;
  91.          GetPlayerHealth(playerid, RecoverHealth);
  92.          SetPlayerHealth(playerid, RecoverHealth+1);
  93.          return 1;
  94.          }
  95.          return 1;
  96.      }
  97.      return 1;
  98. }
  99. public OnPlayerDisconnect(playerid, reason)
  100. {
  101.      Delete3DTextLabel(DyingTextWarn[playerid]);
  102.      ClearAnimations(playerid);
  103.      return 1;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement