Shooting distance? - 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: Shooting distance? (
/showthread.php?tid=500338)
Shooting distance? -
Lajko1 - 12.03.2014
How can I make if player is far away from shooter he will receive lower amount of damage? And if he is closer he will receive bigger amount of damage? (if is even possible)
Re: Shooting distance? -
JonathanFeitosa - 12.03.2014
Yes, but is not fully functional. The Blood of the player will have to come down, then up.
Re: Shooting distance? -
Matess - 12.03.2014
It is possible with these functions:
pawn Код:
OnPlayerTakeDamage
OnPlayerGiveDamage
SetPlayerTeam
Re: Shooting distance? -
Lajko1 - 12.03.2014
I think you didn't understand what I want, let me try to ask again, DISTANCE between shooter and target, for example if they are close enough (1-3 meters) shooter will kill him instantly if distance is more then 3 meters he will receive lower amount of damage.
Re: Shooting distance? -
Lordzy - 12.03.2014
Use the callbacks such as "OnPlayerGiveDamage" and "OnPlayerTakeDamage" to do that. And if you want to lower the damage being done than default damage, I suggest you to set player's team and then manage the damage. While using these callbacks, use
GetPlayerDistanceFromPoint function to determine how meters you're away from the player.
For 3z:
Use OnPlayerWeaponShot. And here's an example:
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(hittype == HIT_TYPE_PLAYER)
{
new
Float:X, Float:Y, Float:Z;
GetPlayerPos(hitid, X, Y, Z);
if(GetPlayerDistanceFromPoint(playerid, X, Y, Z) < 4.0)
{
//More damage?
}
else
{
//If more than 3m.
}
}
return 1;
}
The same can be done on with "OnPlayerGiveDamage" or "OnPlayerTakeDamage" in case if it's not for 3x or for 3z versions with lagcompmode Off.
Re: Shooting distance? -
Lajko1 - 12.03.2014
I will try that + I can't see example, you forgot to post it :P
Re: Shooting distance? -
Matess - 12.03.2014
Yes but you must disable "normal system" and replace it by your own. For example under OnPlayerTakeDamage you will count distance between shooter and target. After it you will decrease the amount of health in spite of distance.
Re: Shooting distance? -
CuervO - 12.03.2014
Example taken from my TF2 Gamemode:
http://pastebin.com/VaS1qSAG
That's a complete scriptside health system where all the damage is recalculated and modified, I do have a distance reduction formula too; The only downside with this is that you need a custom player label system, since if you set a player's health to infinite the other players will not see the health bar of the player decrease when being damaged.