//try this under take damage
new Float:loosedamage;
GetPlayerHealth(playerid, loosedamage);
SetPlayerHealth(playerid, loosedamage + amount);
new x = 1 + random(50); //made change here
SetPlayerHealth(loosedamage - x); //change here
Damage the player gets is calculated by angle and distance
let me see pawn Код:
|
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID)
{
new Float: Dpos[3];
GetPlayerPos(issuerid, Dpos[0], Dpos[1], Dpos[2]);
new Float:dmg=0.0;
switch(weaponid)
{
//you would change these IDs around or whatever
//dmg=5+random(maxrandomvalue); - i use 5+the random to ensure we will always at least do 5 damage
case 2,3,5..7,10..16: dmg=15.0;
case 8: dmg=50.0;
case 22, 30: dmg=40.0;
case 23, 31: dmg=30.0;
case 24: dmg=80.0;
case 28,29,32: dmg=25.0;
case 33,34: dmg=70.0;
case 41,42: dmg=0.2;
default: dmg=amount; //this is for weapon ID's we don't specify
}
if(GetPlayerDistanceFromPoint(playerid, Dpos[0], Dpos[1], Dpos[2]) < 2.0) dmg = 2.0; //if they go up and hit the player, we don't want it to do the full damage of the weaponid
new Float:old_hp, Float:old_armor;
GetPlayerHealth(playerid, old_hp);
GetPlayerArmour(playerid, old_armor);
if(old_armor >= dmg) SetPlayerArmour(playerid, (old_armor-dmg));
else if(old_armor < dmg)
{
new Float:tmp_amount=(old_armor-dmg);
SetPlayerArmour(playerid, 0);
SetPlayerHealth(playerid, (old_hp+tmp_amount));
}
else if(old_hp > dmg) SetPlayerHealth(playerid, (old_hp-dmg));
else SetPlayerHealth(playerid, 0.0);
}
return 1;
}