#DEFINE MAXWEAPONBUTTGUN 15 // cold steel <= 15
OnPlayerAnimButtGun(playerid,weapondid)
{
if(weapondid > MAXWEAPONBUTTGUN) // > at the cold steel you can modified this if you want... my GM dont use other cold steel
{
if(strcmp(GetPlayerAnimationNameEx(playerid), "GUN_BUTT", true)== 0 || strcmp(GetPlayerAnimationNameEx(playerid), "GUN_STAND", true) == 0 || strcmp(GetPlayerAnimationNameEx(playerid), "GUN_BUTT_crouch", true) == 0 ) return 1;
}
return 0;
}
GetPlayerAnimationNameEx(playerid)
{
new animlib[32];
new animname[32];
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
return animname;
}
if(!OnPlayerAnimButtGun(issuerid,weaponid)) //false
{
//code
}
// OR
if(OnPlayerAnimButtGun(issuerid,weaponid)) // true
{
//code
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
static Float:damage, Float:health, Float:armour;
if(issuerid != INVALID_PLAYER_ID)
{
if(amount == 2.64) // Detects default damage butt attack.
{
damage = 5.0; // Sets a new damage to the butt attack (editable).
}
GetPlayerHealth(playerid, heaalth);
GetPlayerArmour(playerid, armour);
if(armour)
{
if(armour > damage) SetPlayerArmour(playerid, armour-damage);
else
{
SetPlayerArmour(playerid, 0.0);
armour = damage-armour;
if(armour >= health) SetPlayerHealth(playerid, 0.0);
else SetPlayerHealth(playerid, health-armour);
}
}
else
{
if(health > damage) SetPlayerHealth(playerid, health-damage);
else SetPlayerHealth(playerid, 0.0);
}
}
return 1;
}
the problem is sometimes a player who damages another one like this, it won't be synced on their screen and only the person you damaged's screen. to be honest, it's more practical (imo) to just detect if a player did < 3 or so damage with any shootable, and IsPlayerInRangeOfPoint.
|
It's simple, default damage or default in singleplayer butt attack is 2.64, which makes my code is to convert that damage you want.
Sorry for my bad english, i'm Argentinan. |
switch(weaponid)
{
case 15: amount = 12;
case 4: amount = 40;
case 5: amount = 12;
case 22: amount = 18;
case 28: amount = 8;
case 29: amount = 10;
case 32: amount = 9;
case 33: amount = 40;
case 34: amount = 50;
}
armour = armour - amount;
if(armour < 0.0)
{
health += armour;
if(health <= 0.0)
{
health = 0.0;
}
armour = 0.0;
}
SetPlayerHealthTakeDamage(playerid, health); // My Func change this
SetPlayerArmourTakeDamage(playerid, armour); // My Func change this
}