How to detect, player damaged?
#1

How to detect this, and how to set damage of X weapon?
Reply
#2

Search for OnPlayerHealthChange callback. You can find it in YSI (YSI\System\YSI_callbacks.own)

Code:
SetDisabledWeapons
Warning: This function is removed in SA-MP 0.3. Alternatively you can return 0 
in OnPlayerUpdate if they use a bad weapon, and change their weapon
if thats what you mean be 'set damage of X weapon'.

Reply
#3

But is there are any forward for takedamage?
Like victim,attacker,damagedone ?
Or only this forward on health change ? :/
Reply
#4

Nope, theres no such thing.. no way you can detect who last shot you, unless you're uber experienced pro scripter and really wanna know
who last shot you, you may be able to script it.. or maybe you can ask SA-MP Team to make such callback in next update, since there is
callback OnPlayerDeath, which detects who killed you, they can probably make OnPlayerGetShot or something.. anyway, good luck!
Reply
#5

Good idea, seif!
Reply
#6

man seif your pro at this..
Reply
#7

Isn't easier to make a forward,finding offsets of it ^_^ in new update
Reply
#8

Quote:
Originally Posted by Seif_
You can do that. All you need is simply a variable that detects the last shooter, and you can detect that by checking who lastly had a weapon and pressed the fire key.
Then, if OnPlayerHealthChange is called, you check if the shooter's angle was facing the victim. If so, he probably shot him. You should also check if they're in a range, not from SF to the LS docks, the guy was probably shooting facing the other player and the other player probably fell at the same time...
And now to see the difference, you can make OnPlayerHealthChange detect the last HP and the new HP. You do last-new.
OnPlayerHealthChange can be made using OnPlayerUpdate.
Why to bother making something, that almost definitely wont work 100% perfect. I once made a system that
detects who sniped you and it worked fine, but considering player's ping, lag and all the other players shooting
around, the idea failed. And weapons such as sawn-off and uzi you can face north and aim east/west at the
same time, which is what players usually do during fights, so facing angle doesnt count in situation like that.
You cant script such a perfect 'who last shot you'-detection with pawno.
Reply
#9

Give this a try:
http://pastebin.com/f3907ba90

'Tis untested at the moment.
(Check my sig for the a_angles include.)

Quote:
Originally Posted by Μαστερμινδ
And weapons such as sawn-off and uzi you can face north and aim east/west at the
same time, which is what players usually do during fights, so facing angle doesnt count in situation like that.
You cant script such a perfect 'who last shot you'-detection with pawno.
Because of that, the best I can do is just check if the player is facing the target within 180 degrees of his/her current facing angle. But it ought do the trick.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)