Advertisement
RaFaeLs

## SA:MP Damage bar by RaFaeL ##

Feb 2nd, 2013
1,167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.94 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3.  
  4. #define COLOR_BAR        0xFF0000FF // First color of 3DText
  5. #define HEALTH_LENGTH    3 // Max langth of damage (100 is 3, 10 is 2, 1 is 1)
  6. #define HEALTH_DRAW      30.0 // Draw distance for the 3DText
  7. #define HEALTH_OFFSET    0.2 // First 3DText offset
  8. #define HEALTH_OFFSETADD 0.01 // Add every update to 3D offser - commant to disable
  9. #define COLOR_DELETE     10 // Color brightnes to delet every update
  10. #define TIME_FIRST       400 // Time from creation to first update
  11. #define TIME_BLOW        66 // Time from update tp update
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     print("\n *** DAMAGE BAR by RaFaeL successfully Loaded! v0.2.1 *** \n");
  16.     return 1;
  17. }
  18.  
  19. public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) {
  20.     if(issuerid == INVALID_PLAYER_ID) return 1; // Skip if Damaged player is invalid
  21.    
  22.     new
  23.         Text3D:bar3D,
  24.         damageStr[HEALTH_LENGTH];
  25.        
  26.     valstr(damageStr, floatround(amount));
  27.     bar3D = Create3DTextLabel(damageStr, COLOR_BAR, 0.0, 0.0, 0.0, HEALTH_DRAW, 0);
  28.     Attach3DTextLabelToPlayer(bar3D, playerid, 0.0, 0.0, HEALTH_OFFSET);
  29.     SetTimerEx("UpdateDamageBar", TIME_FIRST, 0, "iiffii", playerid, _:bar3D, amount, HEALTH_OFFSET, 16, COLOR_BAR);
  30.    
  31.     return 1;
  32. }
  33.  
  34. forward UpdateDamageBar(playerid, Text3D:bar3D, Float:amount, Float:offset, updated, color);
  35. public UpdateDamageBar(playerid, Text3D:bar3D, Float:amount, Float:offset, updated, color) {
  36.     if(!updated--) {
  37.         Delete3DTextLabel(bar3D);
  38.         return 1;
  39.     }
  40.  
  41.     new
  42.         damageStr[HEALTH_LENGTH];
  43.     valstr(damageStr, floatround(amount));
  44.     offset += HEALTH_OFFSETADD;
  45.     color -= COLOR_DELETE;
  46.    
  47.     Update3DTextLabelText(bar3D, color, damageStr);
  48.     #if defined HEALTH_OFFSETADD
  49.         Attach3DTextLabelToPlayer(bar3D, playerid, 0.0, 0.0, offset);
  50.     #endif
  51.     SetTimerEx("UpdateDamageBar", TIME_BLOW, 0, "iiffii", playerid, _:bar3D, amount, offset, updated, color);
  52.     return 1;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement