18.01.2014, 13:19
(
Последний раз редактировалось Abagail; 19.11.2015 в 15:48.
)
Custom Damaging(with bodyparts)
I wanted to explain how you could do custom damaging for specific Body-Parts with the new 0.3z update.
What you'll need:
**Some Scripting Knowledge**
**The 0.3z Pawno Package**
We'll start by setting everything up:
Код:
#include a_samp #define WEAPON_BODY_PART_CHEST 3 #define WEAPON_BODY_PART_CROTCH 4 #define WEAPON_BODY_PART_LEFT_ARM 5 #define WEAPON_BODY_PART_RIGHT_ARM 6 #define WEAPON_BODY_PART_LEFT_LEG 7 #define WEAPON_BODY_PART_RIGHT_LEG 8 #define WEAPON_BODY_PART_HEAD 9
Then, we can either use OnPlayerTakeDamage, or OnPlayerGiveDamage. We'll use OnPlayerTakeDamage for this tutorial. Playerid will represent the player taking the damage, whilst the issuserID will be the person issuing the damage to the playerid. The "amount" float will be representing the amount of health playerid has lost.
The weaponID will be representing the weaponID used by the issuerid. Finally, the bodypart will represent which body-part was shot at, using our defines shown above.
This is what it will look like:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { return 1; }
Код:
if(!IsPlayerConnected(playerid)) return 0; if(!IsPlayerConnected(issuerid)) return 0;
Код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9) { SetPlayerHealth(playerid, 0.0); }
If you want to forbid/ban players using certain weapons such as RPG'S and mini-guns you can use the code found below:
if(issuerid != INVALID_PLAYER_ID && weaponid == 38 )
{
Ban(issuerid);
}
Obviously, replacing the WeaponID with the one you want to forbid. The final code is shown below.
Код:
#include a_samp #define WEAPON_BODY_PART_CHEST 3 #define WEAPON_BODY_PART_CROTCH 4 #define WEAPON_BODY_PART_LEFT_ARM 5 #define WEAPON_BODY_PART_RIGHT_ARM 6 #define WEAPON_BODY_PART_LEFT_LEG 7 #define WEAPON_BODY_PART_RIGHT_LEG 8 #define WEAPON_BODY_PART_HEAD 9 public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart) { if(!IsPlayerConnected(playerid)) return 0; if(!IsPlayerConnected(issuerid)) return 0; if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9) { SetPlayerHealth(playerid, 0.0); } if(issuerid != INVALID_PLAYER_ID && weaponid == 38) { Ban(issuerid); } return 1; }
Resources:
WeaponID'S: https://sampwiki.blast.hk/wiki/Weapons
OnPlayerTakeDamage: https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
I hope this helped you understand this, and if you have any questions at all either PM me or reply here below.
EDIT: I realize there are several grammar mistakes throughout, I'll edit / re-do the tutorial when I have time.