19.01.2014, 19:42
Is possible to raise damage if player is near shooter (issuer)?
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)//If a player shoots another player.
{
if(!IsPlayerConnected(Shooter) || !IsPlayerConnected(Target)) //Error checking
{
return 1;
}
if(GetPlayerDistanceFromPlayer(Shooter, Target) < 10)//Get the distance between the shooter and the target, in this case if it's within 10 game units
{
if(GetPlayerWeapon(Shooter) == 31 || 30)//Get their weapon, in this case an AK47 or M4
{
new Float:pHealth; //Created a float variable to use bellow
GetPlayerHealth(Target, pHealth); //Save the target's health to the variable AFTER the normal damage has been taken
SetPlayerHealth(Target, pHealth-60);//Takes away health points (AGAIN, this is after the normal damage from the shot has been taken into effect)
//SetPlayerHealth(playerid, 2); <- You could do something like this as well, simply setting the player's health to a certain value 0-100.
return 1;//end
}
}
return 1;
}
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)//If a player shoots another player.
{
if(!IsPlayerConnected(Shooter) || !IsPlayerConnected(Target)) //Error checking
{
return 1;
}
if(GetPlayerDistanceFromPlayer(Shooter, Target) < 10)//Get the distance between the shooter and the target, in this case if it's within 10 game units
{
if(GetPlayerWeapon(Shooter) == 31 || 30)//Get their weapon, in this case an AK47 or M4
{
new Float:pHealth; //Created a float variable to use bellow
GetPlayerHealth(Target, pHealth); //Save the target's health to the variable AFTER the normal damage has been taken
SetPlayerHealth(Target, pHealth-60);//Takes away health points (AGAIN, this is after the normal damage from the shot has been taken into effect)
//SetPlayerHealth(playerid, 2); <- You could do something like this as well, simply setting the player's health to a certain value 0-100.
return 1;//end
}
}
else if (GetPlayerDistanceFromPlayer(Shooter, Target) > 10)
{
//code
return 1;
}
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
#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;
}
#include a_samp
#define WEAPON_BODY_PART_TORSO 3
#define WEAPON_BODY_PART_GROIN 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
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,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)
{
new Float:pHealth;
GetPlayerHealth(playerid, pHealth);
new Float:x, Float:y, Float:z;
GetPlayerPos(issuerid, x, y, z);
if(!IsPlayerConnected(playerid)) return 0;
if(!IsPlayerConnected(issuerid)) return 0;
if(issuerid != INVALID_PLAYER_ID && weaponid == 30 && bodypart == 9) // AK, Head
{
if(GetDistanceBetweenPlayers(issuerid, playerid) < 10)
{
SetPlayerHealth(playerid, pHealth-60);
return 1;
}
else if(GetDistanceBetweenPlayers(issuerid, playerid) > 10)
{
SetPlayerHealth(playerid, pHealth-30);
return 1;
}
}
if(issuerid != INVALID_PLAYER_ID && weaponid == 25 && bodypart == 9) // Shotgun, Head
{
if(GetDistanceBetweenPlayers(issuerid, playerid) < 10)
{
SetPlayerHealth(playerid, pHealth-80);
return 1;
}
else if (GetDistanceBetweenPlayers(issuerid, playerid) > 10 && GetDistanceBetweenPlayers(issuerid, playerid) < 15)
{
SetPlayerHealth(playerid, pHealth-40);
return 1;
}
else if (GetDistanceBetweenPlayers(issuerid, playerid) > 15 && GetDistanceBetweenPlayers(issuerid, playerid) < 20)
{
SetPlayerHealth(playerid, pHealth-20);
return 1;
}
else if (GetDistanceBetweenPlayers(issuerid, playerid) > 20)
{
SetPlayerHealth(playerid, pHealth-10);
return 1;
}
}
return 1;
}