CLEO Help Need help to get if actor damaged by player, 051A not working

CLEO related
Status
Not open for further replies.

tieuthienthan

Active member
Joined
Nov 6, 2019
Messages
43
Reaction score
10
Location
Vietnam
Hello there, I'm trying to make a hitmarker on my own. To do so, I need to find out when an actor is hit by $player_actor but now I'm in a mess because the opcode 051A is not working as expected.
What I've tried:
Using ForAllPeds by Opcodex:
Code:
{$CLEO .cs}
wait 10000

while true
    wait 0
    ForAllPeds()
end

:ForAllPeds

    0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0

    000A: 29@ += 0x4

    0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0

    for 30@ = 0 to 35584 step 0x100

        0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0

        000A: 29@ += 0x1

        if and

            0029:  31@ >= 0x00

            001B:  0x80 > 31@

        then

            005A: 31@ += 30@ // got the ped
            if or
                856D:   actor 31@ defined // actor not defined
                003B:   31@ == $PLAYER_ACTOR // my ped
            then
                continue // skip
            end  
            if

                051A:   actor 31@ damaged_by_actor $PLAYER_ACTOR

            then

                0AD1: "You're attacking someone" 1337
                054E: clear_actor 31@ damage

            end        

        end

    end

    return

I tried to use the provided memory in https://gtamods.com/wiki/Memory_Addresses_(SA)
  • CPed +0x764 = [dword] Pointer to the ped that damaged you
the result is still false:

Code:
{$CLEO .cs}
wait 10000

while true
    wait 0
    ForAllPeds()
end

:ForAllPeds

    0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0

    000A: 29@ += 0x4

    0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0

    for 30@ = 0 to 35584 step 0x100

        0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0

        000A: 29@ += 0x1

        if and

            0029:  31@ >= 0x00

            001B:  0x80 > 31@

        then

            005A: 31@ += 30@ // got the ped
            if or
                856D:   actor 31@ defined // actor not defined
                003B:   31@ == $PLAYER_ACTOR // my ped
            then
                continue // skip
            end
            0A96: 24@ = actor 31@ struct
            24@ += 0x764 // last damaged player
            0A8D: 23@ = read_memory 24@ size 4 virtual_protect 0
            if

                003B: 23@ == $PLAYER_ACTOR

            then

                0AD1: "You're attacking someone" 1337
                054E: clear_actor 31@ damage

            end        

        end

    end

    return

Please help me to solve this. Every help is appreciated
SAMP version: 0.3DL
Test server:
HostName: [0.3.DL] ~ Koky's Deathmatch ~ kokysdm.net
Address: 185.198.188.101:7777
 
Last edited:

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,151
Solutions
5
Reaction score
893
Location
Lithuania
One example
PHP:
:DeathInfo
// 0AB1: @DeathInfo 0
0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
for 30@ = 0 to 35584 step 0x100
    0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
    000A: 29@ += 0x1
    if and
        0029: 31@ >= 0x00
        001B: 0x80 > 31@                      
    then
        005A: 31@ += 30@
        if and
        056D:   actor 31@ defined
        803B:   31@ == $PLAYER_ACTOR // not my ped
        then
            if and
            051A:   actor $PLAYER_ACTOR damaged_by_actor 31@
            0118:   actor $PLAYER_ACTOR dead
            then
                0467: clear_actor 31@ last_weapon_damage
                054E: clear_actor $PLAYER_ACTOR damage
                0AB1: @GetInformation 2 of PlayerHandle 31@ ActorActor $PLAYER_ACTOR _Returned: 7@ Health 8@ Armour 9@ ping 10@ nickname 11@ playercolor 12@ weapon 13@ DistanceXYZ 14@
                0AF8: samp add_message_to_chat "{FF0000}You have been killed by {BFBFBF}%s(%d) {FF0000}with weapon ID : %d from a distance of %f meters" color 12@ 11@ 7@ 13@ 14@
                0AF8: samp add_message_to_chat "%s(%d)'s ping (%d), Health (%d), Armour (%d)" 12@ 11@ 7@ 10@ 8@ 9@ 
            end
        end
    end
end
0AB2: ret 0

:GetInformation
Actor.StorePos(0@, 1@, 2@, 3@)
Actor.StoreDeadActorPos($PLAYER_ACTOR, 4@, 5@, 6@)
0B2B: samp 7@ = get_player_id_by_actor_handle 0@
0B25: samp 8@ = get_player_health 7@
0B26: samp 9@ = get_player_armor 7@
0B2A: samp 10@ = get_player_ping 7@
0B36: samp 11@ = get_player_nickname 7@
0B37: samp 12@ = get_player_color 1@
0470: 13@  = actor 0@ current_weapon
050A: 14@ = distance_between_XYZ 1@ 2@ 3@ and_XYZ 4@ 5@ 6@
0AB2: ret 8 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15@
 

tieuthienthan

Active member
Joined
Nov 6, 2019
Messages
43
Reaction score
10
Location
Vietnam
One example
[/php]
Yea but the problem is that in that server, the opcode
051A: actor $PLAYER_ACTOR damaged_by_actor 31@
doesn't work.
I tried to modify a little and sadly nothing showed up when the player_actor is damaged by other actors
PHP:
{$CLEO .cs}
wait 10000

while true
    wait 0 ms
    DeathInfo()
end

:DeathInfo
0A8D: 29@ = read_memory 0xB74490 size 4 virtual_protect 0
29@ += 0x4
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0
for 30@ = 0 to 35584 step 0x100
    0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0
    000A: 29@ += 0x1
    if and
        0029: 31@ >= 0x00
        001B: 0x80 > 31@                     
    then
        005A: 31@ += 30@
        if and
        056D:   actor 31@ defined
        803B:   31@ == $PLAYER_ACTOR // not my ped
        then
            if
            051A:   actor $PLAYER_ACTOR damaged_by_actor 31@
            //0118:   actor $PLAYER_ACTOR dead
            then
                0467: clear_actor 31@ last_weapon_damage
                054E: clear_actor $PLAYER_ACTOR damage
                0AD1: "You're attacked by someone" 5000
            end
        end
    end
end
return

do you have any workarounds ? cause 051A doesn't work properly
 
Status
Not open for further replies.
Top