Help sniper problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help sniper problem (
/showthread.php?tid=559240)
Help sniper problem -
Mijata - 21.01.2015
how to add here headshot only for sniper weapon
pawn Код:
#include <a_samp> /*-------------------------
HeadShot System by Peppe
The faster implementation of a headshot system in SA:MP.
This script requires the new version of SA:MP 0.3b.
http://www.pawnoitalia.forumfree.it
http://www.atlantisgaming.it
-------------------------*/ #define TIMER_INTERVAL 150 new maxPlayers;
public OnFilterScriptInit
(){ maxPlayers
= GetMaxPlayers
();
SetTimer
("CheckHeadShot", TIMER_INTERVAL,
1);
return 1;
} public OnPlayerDeath
(playerid, killerid, reason
){ if(GetPVarInt
(playerid,
"Headshotted") == 1) { SetPVarInt
(playerid,
"Headshotted",
0);
GameTextForPlayer
(playerid,
"~r~Headshotted",
3000,
3);
GameTextForPlayer
(killerid,
"~r~Headshott",
3000,
3);
} return 1;
} forward CheckHeadShot
();
public CheckHeadShot
(){ new index;
for(new playerid; playerid
< maxPlayers; playerid
++) { if(IsPlayerConnected
(playerid
)) { index
= GetPlayerAnimationIndex
(playerid
);
if(index
== 1173 || index
== 1175 || index
== 1177 || index
== 1178) { SetPVarInt
(playerid,
"Headshotted",
1);
SetPlayerHealth
(playerid,
0);
} } } return 1;
}
Re: Help sniper problem -
nGen.SoNNy - 21.01.2015
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPVarInt(playerid, "Headshotted") == 1)
{
if(GetPlayerWeapon(killerid) == 34) // Sniper Rifle
{
SetPVarInt(playerid, "Headshotted", 0);
GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
GameTextForPlayer(killerid, "~r~Headshott", 3000, 3);
}
}
return 1;
}
Re: Help sniper problem -
Mijata - 21.01.2015
now player don't have message headshoted
Re: Help sniper problem -
SickAttack - 21.01.2015
Example - One-shot-kill sniper headshots
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID && weaponid == 34 && bodypart == 9)
{
// One shot to the head to kill with sniper rifle
SetPlayerHealth(playerid, 0.0);
}
return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Re: Help sniper problem -
Mijata - 21.01.2015
it can't work
Re: Help sniper problem -
xVIP3Rx - 21.01.2015
Try one of those, or each.
You could put your codes at only one, but it's better that way and should be synced
pawn Код:
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid, bodypart)
{
if(weaponid == WEAPON_SNIPER && bodypart == 9) //If it's a sniper headshot
{
new Float:h; GetPlayerHealth(damagedid, h);
if(h - amount < 0.1)//If that shot killed him
{
GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
}
}
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(weaponid == WEAPON_SNIPER && bodypart == 9) //If it's a sniper headshot
{
new Float:h; GetPlayerHealth(playerid, h);
if(h - amount < 0.1)//If that shot killed him
{
//Do something
GameTextForPlayer(playerid, "~r~Headshotted", 3000, 3);
}
}
return 1;
}