CLEO Help Damage taken

CLEO related
Status
Not open for further replies.

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Hi,

Is their a opcode to know how many damage I took from a shot ? Something like this: http://wiki.sa-mp.com/wiki/OnPlayerGiveDamage_FR but in cleo.

I could make it with the player health, but I don't know how to get my health at time N-1.

Any solution ?
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Hi, I'm not an expert but I don't think that there is anything like that. You could potentially measure how much hp someone lost but there are few things you should consider...
1. "0B25: samp 0@ = get_player_health 1@" used to be not accurate. It returns the multiplier of 7. So for example if a specific player has 71hp it's going to display to you as 70hp.
2. There's a delay between the moment of shot and the moment of hp change because of the lag. On my server with 2 players online 300ms was enough to compensate it(not checked with Cleo) but it may differ.

You may ask Springfield who made a feature like that in his player informer mod. But I doubt that it uses some more accurate method than manual adjusting the damage because that was his suggestion when he gave me advice about the same problem.
http://ugbase.eu/help-7/relation-between-weapon-damage-and-hp-loss/

springfield link said:
Before displaying damage text.

Code:
if weapon == 24
then 
    if dmgDone == 49
    then dmgDone -= 3
    end
    if dmgDone == 42
    then dmgDone += 4
    end
    if dmgDone == 51
    then dmgDone -= 5
    end
end

drawText dmgDone

It may work for a deagle if the damage is not adjusted by the server to any different value than 46. But for automatic weapons like m4 or mp5 it may not work accurately at all because they give different damage with each hit (correct me if I'm wrong but that's what I observed on Italy Mafia RP where damage is displayed from the server-side when you're at paintball)
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
All right i will check that. With damageinformer.cs I can't have the damage i make (but I saw on youtube that it works for other player) I tried to "decompile" his code but it only shows me hexadecimals.

I will try this with the 300ms (more or less) delay.
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
Well, using SAMPFUNCS 4.0+ you can read http://wiki.sa-mp.com/wiki/OnPlayerGiveDamage_FR

Code:
0BE1: raknet setup_outcoming_RPC_hook @OnPlayerGiveTakeDamage

:OnPlayerGiveTakeDamage
0BE5: raknet 0@ = get_hook_param 0 
0BE5: raknet 1@ = get_hook_param 1 
IF 1@ == 115 //onPlayerGiveTakeDamage
THEN 
    3@ = BitStream.Read(0@, 1)   //0 = give, 1 = take
    4@ = BitStream.Read(0@, 2)   //playerid
    5@ = BitStream.Read(0@, 4)   //ammount
    IF 3@ == 0
    THEN 0AD1: "player %d shot me for %0.1 hp" 700 4@ 5@
    END    
    IF 3@ == 1
    THEN 0AD1: "i shot player %d for %0.1f hp" 800 4@ 5@
    END
END 
0BE0: raknet hook_ret 1
 

Grubitsh

Active member
Joined
Jul 28, 2014
Messages
104
Reaction score
0
Wow, cool, thanks Springfield.

Is their any way to know that information, for other player in SAMP ? Like if someone is shooting at another one (but not me), can I know the ammount of damage ?

I can get the 2 actors that are shooting with a double loop "FOR ALL PEDS", i store them in variable 31@ and 26@ then

if
051A:  actor 31@ damaged_by_actor 26@
then

[What amount of damage is taken by actor 31@]
[instruction]

end
 
Status
Not open for further replies.
Top