Team damage / 2, How to do this? -
AnthonyTimmers - 15.02.2014
Is it possible to half the damage that you do on teammembers? I don't want to completely disable team damage, though, so don't say I can do that, cause I know how to
Re: Team damage / 2, How to do this? -
redneckvideogamer - 15.02.2014
Try adding this:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
new Float:health;
new Float:sum = GetPlayerHealth(damagedid,health) + amount / 2;
if(pInfo[damagedid][Team] == pInfo[playerid][Team]) //Switch to your team variables
{
SetPlayerHealth(damagedid,sum); //Setting the damaged teammate's health to whatever he had plus half the damage he took
}
return 1;
}
Re: Team damage / 2, How to do this? -
AnthonyTimmers - 15.02.2014
Quote:
Originally Posted by redneckvideogamer
Try adding this:
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart) { new Float:health; new Float:sum = GetPlayerHealth(damagedid,health) + amount / 2; if(pInfo[damagedid][Team] == pInfo[playerid][Team]) //Switch to your team variables { SetPlayerHealth(damagedid,sum); //Setting the damaged teammate's health to whatever he had plus half the damage he took } return 1; }
|
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if (GodMode[playerid] == 1)
{
SetPlayerHealth(playerid, 0x7F800000);
}
else
{
if(issuerid != INVALID_PLAYER_ID)
{
if (gTeam[playerid] == gTeam[issuerid])
{
new Float:Health;
new Float:NewHealth = GetPlayerHealth(playerid,Health) + (0.5 * amount);
SetPlayerHealth(playerid, NewHealth);
}
}
}
return 1;
}
Just made this, and I think it's about the same.
Would it work? I'd test it out but I don't have anyone to test it out on :<
Re: Team damage / 2, How to do this? -
redneckvideogamer - 15.02.2014
Send me IP via PM and I'll help you out.
(Either use Hamachi or Port-Forward), but it should work.
Re: Team damage / 2, How to do this? -
AnthonyTimmers - 16.02.2014
It's working now, but if anyone has a way to get this effect done better please let me know.
Re: Team damage / 2, How to do this? -
CyNiC - 16.02.2014
Try(but preserve your actual code cus I didnt test this):
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if (GodMode[playerid] == 1)
{
SetPlayerHealth(playerid, 0x7F800000);
}
else
{
if(issuerid != INVALID_PLAYER_ID)
{
if (gTeam[playerid] == gTeam[issuerid])
{
new Float:Health,Float:Armour;
GetPlayerHealth(playerid,Health);
GetPlayerArmour(playerid,Armour);
if(amount < Health+Armour) //avoid double kill for playerid
{
if(Armour>0.0) {
Armour -= amount/2.0;
if(Armour < 0.0) Health += Armour;
}
else {
Health -= amount/2.0;
}
SetPlayerArmour(playerid,(Armour>0)?(Armour):(0.0));
SetPlayerHealth(playerid, Health);
}
}
}
}
return 1;
}
Re: Team damage / 2, How to do this? -
AnthonyTimmers - 16.02.2014
What does this part do:
SetPlayerArmour(playerid,(Armour>0)?(Armour)
0.0) );
I don't understand the
(Armour>0)?(Armour) : (0,0) part..
Does it say is Armour more than 0, then armour = Armour, else armour = 0.0?
Re: Team damage / 2, How to do this? -
CyNiC - 16.02.2014
Yes, I put
ternary operator for avoid negative armour.