Advertisement
Essle

New weapon damage

Apr 30th, 2013
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.65 KB | None | 0 0
  1. stock Float:GetWeaponDamage(weaponid) // указываем свой урон от определенного оружия.
  2. {    
  3.     switch(weaponid)    
  4.     {        
  5.         case WEAPON_BRASSKNUCKLE:           return 1.0;        
  6.         case WEAPON_GOLFCLUB:               return 1.0;        
  7.         case WEAPON_NITESTICK:              return 1.0;        
  8.         case WEAPON_KNIFE:                  return 1.0;        
  9.         case WEAPON_BAT:                    return 1.0;        
  10.         case WEAPON_SHOVEL:                 return 1.0;        
  11.         case WEAPON_POOLSTICK:              return 1.0;        
  12.         case WEAPON_KATANA:                 return 1.0;        
  13.         case WEAPON_CHAINSAW:               return 1.0;        
  14.         case WEAPON_DILDO:                  return 1.0;        
  15.         case WEAPON_DILDO2:                 return 1.0;        
  16.         case WEAPON_VIBRATOR:               return 1.0;        
  17.         case WEAPON_VIBRATOR2:              return 1.0;        
  18.         case WEAPON_FLOWER:                 return 1.0;        
  19.         case WEAPON_CANE:                   return 1.0;        
  20.         case WEAPON_GRENADE:                return 1.0;        
  21.         case WEAPON_TEARGAS:                return 1.0;        
  22.         case WEAPON_MOLTOV:                 return 1.0;        
  23.         case WEAPON_COLT45:                 return 1.0;        
  24.         case WEAPON_SILENCED:               return 1.0;        
  25.         case WEAPON_DEAGLE:                 return 1.0;        
  26.         case WEAPON_SHOTGUN:                return 1.0;        
  27.         case WEAPON_SAWEDOFF:               return 1.0;        
  28.         case WEAPON_SHOTGSPA:               return 1.0;        
  29.         case WEAPON_UZI:                    return 1.0;        
  30.         case WEAPON_MP5:                    return 1.0;        
  31.         case WEAPON_AK47:                   return 1.0;        
  32.         case WEAPON_M4:                     return 1.0;        
  33.         case WEAPON_TEC9:                   return 1.0;        
  34.         case WEAPON_RIFLE:                  return 1.0;        
  35.         case WEAPON_SNIPER:                 return 1.0;        
  36.         case WEAPON_ROCKETLAUNCHER:         return 1.0;        
  37.         case WEAPON_HEATSEEKER:             return 1.0;        
  38.         case WEAPON_FLAMETHROWER:           return 1.0;        
  39.         case WEAPON_MINIGUN:                return 1.0;        
  40.         case WEAPON_SATCHEL:                return 1.0;        
  41.         case WEAPON_SPRAYCAN:               return 1.0;        
  42.         case WEAPON_FIREEXTINGUISHER:       return 1.0;        
  43.         default:                            return 100.0;    
  44.     }    
  45.     return 0.0;
  46. }
  47.  
  48. static bool:CALLED = false;
  49.  
  50. #define UPDATE_DAMAGE_TIME          300 // время в миллисекундах. после нанесения урона через это время установится 255-ая команда.
  51. #define SLOT_TEAM                   1   // если в моде не используется SetPlayerTeam, то значение не менять.
  52.  
  53. public OnGameModeInit()
  54. {    
  55.     CALLED = funcidx("damage_OnPlayerGiveDamage") != -1;    
  56.     SetTeamCount(MAX_PLAYERS);    
  57.     if(funcidx("damage_OnGameModeInit") != -1) return CallLocalFunction("damage_OnGameModeInit", "");    
  58.     else return 1;
  59. }
  60.  
  61. #if defined _ALS_OnGameModeInit    
  62.     #undef OnGameModeInit
  63. #else    
  64.     #define _ALS_OnGameModeInit
  65. #endif
  66. #define OnGameModeInit damage_OnGameModeInit
  67. forward damage_OnGameModeInit();
  68.  
  69. public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
  70. {    
  71.     if(playerid != damagedid && playerid != INVALID_PLAYER_ID)    
  72.     {        
  73.         SetPlayerTeam(playerid, SLOT_TEAM);        
  74.         SetPlayerTeam(damagedid, SLOT_TEAM);        
  75.         new Float:health[2];      
  76.         GetPlayerHealth(damagedid, health[0]);        
  77.         GetPlayerArmour(damagedid, health[1]);            
  78.         if(health[1] > 0.0)        
  79.         {            
  80.             health[1] -= GetWeaponDamage(weaponid);            
  81.             if(health[1] < 0.0)            
  82.             {                
  83.                 health[0] -= -health[1];                
  84.                 health[1] = 0.0;            
  85.             }        
  86.         }            
  87.         else health[0] -= GetWeaponDamage(weaponid);        
  88.         SetPlayerHealth(damagedid, health[0]);        
  89.         SetPlayerArmour(damagedid, health[1]);        
  90.         SetTimerEx("DeleteOldWeaponDamage", UPDATE_DAMAGE_TIME, false, "ii", damagedid, playerid);    
  91.     }    
  92.     return (CALLED) ? CallLocalFunction("damage_OnPlayerGiveDamage", "iifi", playerid, damagedid, amount, weaponid) : 1;
  93. }
  94.  
  95. #if defined _ALS_OnPlayerGiveDamage    
  96.     #undef OnPlayerGiveDamage
  97. #else    
  98.     #define _ALS_OnPlayerGiveDamage
  99. #endif
  100. #define OnPlayerGiveDamage damage_OnPlayerGiveDamage
  101. forward damage_OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid);
  102.  
  103. forward DeleteOldWeaponDamage(damagedid, playerid);
  104. public DeleteOldWeaponDamage(damagedid, playerid)
  105. {    
  106.     SetPlayerTeam(playerid, 255);    
  107.     SetPlayerTeam(damagedid, 255);    
  108.     return 1;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement