Onplayetgetshoot -
jamesmercer1947 - 30.04.2013
Hello, I am making a system by which if ill hit a bullet of M4 to someone then he/ she will loose 50% of his HP/ armo.
How can I do it with this function?
Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
new string[128], victim[MAX_PLAYER_NAME], attacker[MAX_PLAYER_NAME];
new weaponname[24];
GetPlayerName(playerid, attacker, sizeof (attacker));
GetPlayerName(damagedid, victim, sizeof (victim));
GetWeaponName(weaponid, weaponname, sizeof (weaponname));
format(string, sizeof(string), "%s has made %.0f damage to %s, weapon: %s", attacker, amount, victim, weaponname);
SendClientMessageToAll(0xFFFFFFFF, string);
return 1;
}
Thank you
Re: Onplayetgetshoot -
Pottus - 30.04.2013
OnPlayerGiveDamage is when you shoot the player on your screen you probably want OnPlayerTakeDamage.
Re: Onplayetgetshoot -
RVRP - 30.04.2013
Quote:
Originally Posted by [uL]Pottus
OnPlayerGiveDamage is when you shoot the player on your screen you probably want OnPlayerTakeDamage.
|
To extend on Pottus' point, you'll want to check if the weaponID is equal to that of an M4, and then use SetPlayerHealth to change the health of the player hit by a fraction of the total amount.
Re: Onplayetgetshoot -
jamesmercer1947 - 30.04.2013
Sorry, I didn't get you properly..
Re: Onplayetgetshoot -
Pottus - 30.04.2013
Also keep in mind you can't set weapon damage less than the maximum damage of that weapon because the player would already be dead!
Re: Onplayetgetshoot -
RajatPawar - 30.04.2013
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(weaponid == 31)
{
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealht(playerid, health - 50);
}
}
return 1;
}
This is the basic code.
You need to modify it to add armour loss, checking if the health doesn't go beyond 0, and all that!
Re: Onplayetgetshoot -
RVRP - 30.04.2013
Quote:
Originally Posted by Rajat_Pawar
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid) { if(issuerid != INVALID_PLAYER_ID) { if(weaponid == 31) { new Float:health; GetPlayerHealth(playerid, health); SetPlayerHealht(playerid, health - 50); } } return 1; }
This is the basic code.
You need to modify it to add armour loss, checking if the health doesn't go beyond 0, and all that!
|
He wants their health to decrease by 50%, not 50. It doesn't make much sense considering theoretically the player would never die, but mine as well give him what he asked for.
Instead of subtracting 50, you would divide the current player's health by 2.
Re: Onplayetgetshoot -
KingHual - 30.04.2013
Don't forget to set all players to the same team to eliminate default weapon damage!
Re: Onplayetgetshoot -
Pottus - 30.04.2013
Quote:
Originally Posted by king_hual
Don't forget to set all players to the same team to eliminate default weapon damage!
|
What are you smoking ? He's using OnPlayerTakeDamage(), OnPlayerGiveDamage() was definitely a mistake on his part.
@RVRP That would only work if he has 11hp or more. Your right in theory he would never die but in practice he will die at 10hp or less no matter what.
Re: Onplayetgetshoot -
KingHual - 30.04.2013
Quote:
Originally Posted by [uL]Pottus
What are you smoking ? He's using OnPlayerTakeDamage(), OnPlayerGiveDamage() was definitely a mistake on his part.
|
It does not matter the slightest bit. If they don't set the players to the same team, both the damage he would like AND the default damage would be taken, and that messes things up. In other words, setting the players to the same team means much more control over damage. There are plenty of tutorials on that. Also, I don't smoke.