garrylie

Fade In/Out after death

Jul 29th, 2013
1,507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.71 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define DELAY 5
  4. #define RGBToHex(%0,%1,%2,%3) %0 << 24 | %1 << 16 | %2 << 8 | %3
  5.  
  6. new PlayerText:Background[MAX_PLAYERS];
  7. new bool:IsPlayerDead[MAX_PLAYERS];
  8.  
  9. public OnFilterScriptInit()
  10. {
  11.     for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
  12.     {
  13.         if (IsPlayerConnected(playerid)) OnPlayerConnect(playerid);
  14.     }
  15.     return 1;
  16. }
  17.  
  18. public OnPlayerConnect(playerid)
  19. {
  20.     Background[playerid] = CreatePlayerTextDraw(playerid, 320, 0, "_");
  21.     PlayerTextDrawUseBox(playerid, Background[playerid], 1);
  22.     PlayerTextDrawLetterSize(playerid, Background[playerid], 1.0, 49.6);
  23.     PlayerTextDrawTextSize(playerid, Background[playerid], 1.0, 640);
  24.     PlayerTextDrawBoxColor(playerid, Background[playerid], 0x00000000);
  25.     PlayerTextDrawAlignment(playerid, Background[playerid], 2);
  26.     return 1;
  27. }
  28.  
  29. public OnPlayerDeath(playerid, killerid, reason)
  30. {
  31.     if (IsPlayerDead[playerid]) return 1;
  32.     IsPlayerDead[playerid] = true;
  33.     SetTimerEx("FadeOut", DELAY, false, "id", playerid, 0);
  34.     return 1;
  35. }
  36.  
  37. public OnPlayerSpawn(playerid)
  38. {
  39.     IsPlayerDead[playerid] = false;
  40.     SetTimerEx("FadeIn", DELAY, false, "id", playerid, 255);
  41.     return 1;
  42. }
  43.  
  44. forward FadeOut(playerid, A);
  45. public FadeOut(playerid, A)
  46. {
  47.     PlayerTextDrawBoxColor(playerid, Background[playerid], RGBToHex(0,0,0,A));
  48.     PlayerTextDrawShow(playerid, Background[playerid]);
  49.     if (A < 255) SetTimerEx("FadeOut", DELAY, false, "id", playerid, A+1);
  50. }
  51.  
  52. forward FadeIn(playerid, A);
  53. public FadeIn(playerid, A)
  54. {
  55.     PlayerTextDrawBoxColor(playerid, Background[playerid], RGBToHex(0,0,0,A));
  56.     PlayerTextDrawShow(playerid, Background[playerid]);
  57.     if (A) SetTimerEx("FadeIn", DELAY, false, "id", playerid, A-1); else PlayerTextDrawHide(playerid, Background[playerid]);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment