Advertisement
danutlsrp

Damage System [LS-RP Release 19MAY]

May 19th, 2017
792
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.69 KB | None | 0 0
  1. public OnPlayerDeath( playerid, killerid, reason ){
  2. ResetPlayerDamages( playerid ) ;
  3. return 1 ;
  4. }
  5.  
  6. SetBrutallyWounded( playerid ){
  7. new
  8. stringinfo[ 128 ] ;
  9.  
  10. GameTextForPlayer(playerid, "~b~Brutally Wounded", 7000, 3);
  11. ApplyAnimation( playerid, "WUZI", "CS_Dead_Guy", 4.1, 0, 1, 1, 1, 0, 1 ) ;
  12. SetIntVar( playerid, "BrutallyWounded", 1 ) ;
  13.  
  14. format( stringinfo, sizeof( stringinfo ), "(( Has been injured %d times,\n /damages %d for more information.\n ))", injuredtimes[ playerid ], playerid ) ;
  15. dmginfo[ playerid ] = Create3DTextLabel( stringinfo, 0xFF6347FF, 30.0, 40.0, 0.0, 20.0, 0, 0 ) ;
  16. Attach3DTextLabelToPlayer( dmginfo[ playerid ], playerid, 0.0, 0.0, 0.0 ) ;
  17.  
  18. SCM( playerid, COLOR_LIGHTRED, "You were brutally wounded, now if a medic or anyone else doesn't save you, you will die." ) ;
  19. SCM( playerid, COLOR_LIGHTRED, "To accept death type /acceptdeath" ) ;
  20. SCMEx( playerid, COLOR_LIGHTRED, "(( Has been injured %d times, /damages %d for more information. )) ", injuredtimes[ playerid ], playerid ) ;
  21. SCM( playerid, LSFD_COLOR, "EMT: Your medical bills are $1550" ) ;
  22.  
  23. GiveCash( playerid, -1550 ) ;
  24. return 1 ;
  25. }
  26.  
  27. SetDead( playerid ){
  28. SetIntVar( playerid, "BrutallyWounded", 3 ) ;
  29. Update3DTextLabelText( dmginfo[ playerid ], 0xFF6347FF, "(( THIS PLAYER IS DEAD ))" ) ;
  30. SCM( playerid, COLOR_YELLOWG, "-> You're now dead. You need to wait 60 seconds and then you'll get the ability to /respawnme." ) ;
  31. return 1 ;
  32. }
  33.  
  34. timer oneSecdmg[ 1000 ]( playerid, count ){
  35. _weapon_damage_player[ playerid ][ count ][ SinceDMG ] ++ ;
  36.  
  37. #if defined SVDEBUG
  38. SCMEx( playerid, -1, "damage %d: made %d seconds ago", count, _weapon_damage_player[ playerid ][ count ][ SinceDMG ] ) ;
  39. #endif
  40. }
  41.  
  42. AddKevlarHit( playerid, damageid, weaponid ){
  43. _weapon_damage_player[ playerid ][ damageid ][ KevlarHit ] = _weapon_damage_data[ weaponid ][ ArmorPen ] ;
  44. return 1 ;
  45. }
  46.  
  47. InsertDamage( playerid, weaponid, bodypart ){
  48. new
  49. Float: armour ;
  50.  
  51. _weapon_damage_player[ playerid ][ injuredtimes[ playerid ] ][ Weapon ] = weaponid ;
  52. _weapon_damage_player[ playerid ][ injuredtimes[ playerid ] ][ Bodypart ] = bodypart ;
  53. _weapon_damage_player[ playerid ][ injuredtimes[ playerid ] ][ Amount ] = _weapon_damage_data[ weaponid ][ DamageHP ] ;
  54. _weapon_damage_player[ playerid ][ injuredtimes[ playerid ] ][ Time ] = repeat oneSecdmg( playerid, injuredtimes[ playerid ] ) ;
  55.  
  56. GetPlayerArmour( playerid, armour ) ;
  57. if( armour > 1 ){
  58. SetPlayerArmour( playerid, armour-_weapon_damage_data[ weaponid ][ ArmorPen ] ) ;
  59. AddKevlarHit( playerid, injuredtimes[ playerid ], weaponid ) ;
  60. }
  61.  
  62. #if defined SVDEBUG
  63. SCMEx( playerid, -1, "damage %d: weaponid: %d, bodypart: %d, amount: %f", injuredtimes[ playerid ], weaponid, bodypart, _weapon_damage_player[ playerid ][ injuredtimes[ playerid ] ][ Amount ] ) ;
  64. #endif
  65.  
  66. injuredtimes[ playerid ] ++ ;
  67. return 1 ;
  68. }
  69.  
  70. ResetPlayerDamages( playerid ){
  71. SetIntVar( playerid, "BrutallyWounded", 0 ) ;
  72. Delete3DTextLabel( dmginfo[ playerid ] );
  73. SetIntVar( playerid, "LegShot", 0 ) ;
  74. SetPlayerHealth( playerid, 100 ) ;
  75. ClearAnimations( playerid ) ;
  76.  
  77. for( new i; i <= injuredtimes[ playerid ]; i++ ){
  78. _weapon_damage_player[ playerid ][ i ][ SinceDMG ] = 0 ;
  79. _weapon_damage_player[ playerid ][ i ][ Weapon ] = 0 ;
  80. _weapon_damage_player[ playerid ][ i ][ Bodypart ] = 0 ;
  81. _weapon_damage_player[ playerid ][ i ][ Amount ] = 0 ;
  82. _weapon_damage_player[ playerid ][ i ][ KevlarHit ] = 0 ;
  83. stop _weapon_damage_player[ playerid ][ i ][ Time ] ;
  84.  
  85. #if defined SVDEBUG
  86. SCMEx( playerid, -1, "damage %d cleared!", i ) ;
  87. #endif
  88. }
  89.  
  90. injuredtimes[ playerid ] = 0 ;
  91. playerdead[ playerid ] = 0 ;
  92. return 1 ;
  93. }
  94.  
  95. DisplayDamages( playerid, pid ){
  96. new
  97. damagesmsg[ 1024 ],
  98. dialogname[ 32 ] ;
  99. for( new i; i <= injuredtimes[ pid ]; i++ ){
  100. if( _weapon_damage_player[ pid ][ i ][ Bodypart ] != 0 ){
  101. format( damagesmsg, sizeof( damagesmsg ), "%s%d.0000 dmg from %s to %s (KEVLARHIT: %d) %d s ago\n", damagesmsg, _weapon_damage_player[ pid ][ i ][ Amount ], GetWeaponNameEx( _weapon_damage_player[ pid ][ i ][ Weapon ] ), GetBodyPartName( _weapon_damage_player[ pid ][ i ][ Bodypart ] ), _weapon_damage_player[ pid ][ i ][ KevlarHit ], _weapon_damage_player[ pid ][ i ][ SinceDMG ] ) ;
  102. }
  103. else if( i == 0 && _weapon_damage_player[ pid ][ i ][ Bodypart ] == 0 ){ format( damagesmsg, sizeof( damagesmsg ), "There's no damage to be shown..." ) ; }
  104. }
  105. format( dialogname, sizeof( dialogname ), "%s", GetPlayersName( pid ) ) ;
  106. ShowDialog( playerid, Show:<PlayerDamages>, DIALOG_STYLE_LIST, dialogname, damagesmsg, "Close", "" ) ;
  107. format( damagesmsg, sizeof( damagesmsg ), "" ) ;
  108. return 1 ;
  109. }
  110.  
  111.  
  112. public OnPlayerGiveDamage( playerid, damagedid, Float: amount, weaponid, bodypart ){
  113. return 1 ;
  114. }
  115.  
  116. public OnPlayerTakeDamage( playerid, issuerid, Float: amount, weaponid, bodypart ){
  117. new
  118. Float: health,
  119. Float: armour,
  120. wepid = GetPlayerWeapon( issuerid ) ;
  121.  
  122. GetPlayerHealth( playerid, health ) ;
  123. GetPlayerArmour( playerid, armour ) ;
  124.  
  125. if( GetIntVar( playerid, "gLogged" ) == 1 ){
  126. if( IsValidCRPWeapon( weaponid ) ){
  127. if( health > 25 ){
  128. if( GetIntVar( playerid, "BrutallyWounded" ) == 0 ){
  129. if( _weapon_damage_data[ wepid ][ DamageHP ] > health ){
  130. SetPlayerHealth( playerid, health-( _weapon_damage_data[ wepid ][ DamageHP ] / 3 ) ) ;
  131. InsertDamage( playerid, weaponid, bodypart ) ;
  132. }else{
  133. InsertDamage( playerid, weaponid, bodypart ) ;
  134. SetPlayerHealth( playerid, health-_weapon_damage_data[ wepid ][ DamageHP ] ) ;
  135. }
  136. }if( bodypart == BODY_PART_RIGHT_LEG || bodypart == BODY_PART_LEFT_LEG ){
  137. SetIntVar( playerid, "LegShot", 1 ) ;
  138. }
  139. }else if( health <= 25 ){
  140. if( GetIntVar( playerid, "BrutallyWounded" ) == 0 ){
  141. SetBrutallyWounded( playerid ) ;
  142. }else if( GetIntVar( playerid, "BrutallyWounded" ) == 1 ){
  143. SetIntVar( playerid, "BrutallyWounded", 2 ) ;
  144. }
  145. }
  146. }else{
  147. AntiWeaponCheats( issuerid ) ;
  148. }
  149. }
  150. return 1;
  151. }
  152.  
  153. public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ ) {
  154. if( hittype == BULLET_HIT_TYPE_PLAYER ){
  155. new
  156. Float: health,
  157. Float: armour ;
  158.  
  159. GetPlayerHealth( hitid, health ) ;
  160. GetPlayerArmour( hitid, armour ) ;
  161.  
  162. if( health <= 25 && GetIntVar( hitid, "BrutallyWounded" ) == 2 ) {
  163. SetDead( hitid ) ;
  164. }
  165. }
  166. return 1;
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement