20.01.2014, 12:35
Hey guys I'm new with 0.3z RC and I want to raise damage if player is closer to shooter, will this code work ?
Okay here is an example what I've made:
Will this work?
Also will this range between players work?
Okay here is an example what I've made:
pawn Код:
#include a_samp
#define WEAPON_BODY_PART_CHEST 1
#define WEAPON_BODY_PART_CROTCH 2
#define WEAPON_BODY_PART_LEFT_ARM 3
#define WEAPON_BODY_PART_RIGHT_ARM 4
#define WEAPON_BODY_PART_LEFT_LEG 5
#define WEAPON_BODY_PART_RIGHT_LEG 6
#define WEAPON_BODY_PART_HEAD 7
forward Float:GetDistanceBetweenPlayers(issuerid,playerid);
public Float:GetDistanceBetweenPlayers(issuerid,playerid)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(issuerid) || !IsPlayerConnected(playerid)) {
return -1.00;
}
GetPlayerPos(issuerid,x1,y1,z1);
GetPlayerPos(playerid,x2,y2,z2);
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}
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 == 7)
{
if(GetDistanceBetweenPlayers(issuerid, playerid) < 10)
{
new Float:pHealth;
GetPlayerHealth(playerid, pHealth);
SetPlayerHealth(playerid, pHealth-60);
return 1;
}
else if (GetDistanceBetweenPlayers(issuerid, playerid) > 10)
{
new Float:pHealth;
GetPlayerHealth(playerid, pHealth);
SetPlayerHealth(playerid, pHealth-30);
return 1;
}
}
return 1;
}
Also will this range between players work?