CLEO Help Get the closest ID ( PROBLEM )

CLEO related
Status
Not open for further replies.

kool

Active member
Joined
Jun 4, 2016
Messages
89
Reaction score
0
I used this script to make Get the closest ID keybinder and it doesn't work.
code is by springfield.




[img=329x30]https://image.prntscr.com/image/TXqEahiKSsi591NssKRVyg.png[/img]

CODE : 

{$CLEO}
0000:
 
REPEAT
    WAIT 0
UNTIL 0AFA:
 
WHILE TRUE
WAIT 0
    IF AND
        0AB0: 2
        056D: actor $PLAYER_ACTOR defined
        0B61: samp is_local_player_spawned
    THEN
        CALL @GetClosestPed 0 2@       
        IF 056D: actor 2@ defined
        THEN
            IF 0B2B: samp 3@ = get_player_id_by_actor_handle 2@
            THEN say"/pm %i test" 3@ 
            END
        END
    END
END
 
 
:GetClosestPed
var
0@ : float
5@ : float
end
0@ = 600.0
1@ = -1
 
00A0: $PLAYER_ACTOR 2@ 3@ 4@
 
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@
         
        if 003B: 31@ == $PLAYER_ACTOR
        then continue
        end
         
        00A0: 31@ 6@ 7@ 8@
        0509: 5@ = distance_between_XY 2@ 3@ 6@ 7@
 
        if 5@ < 0@
        then
            0087: 0@ = 5@
            0085: 1@ = 31@
        end
    end
end
 
0AB2: ret 1 1@
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,126
Solutions
1
Reaction score
158
Code:
{$CLEO}
0000:

alloc 31@ 200
 
REPEAT
    WAIT 0
UNTIL 0AFA:
 
WHILE TRUE
WAIT 0
    IF AND
        0AB0: 2
        056D: actor $PLAYER_ACTOR defined
        0B61: samp is_local_player_spawned
    THEN
        CALL @GetClosestPed 0 2@       
        IF 056D: actor 2@ defined
        THEN
            IF 0B2B: samp 3@ = get_player_id_by_actor_handle 2@
            //THEN chatmsg "/pm %i test" -1 3@ 
            THEN
                format 31@ "/pm %i test" 3@ 
                say 31@
                wait 1000
            END
        END
    END
END
 
 
:GetClosestPed
var
0@ : float
5@ : float
end
0@ = 600.0
1@ = -1
 
00A0: $PLAYER_ACTOR 2@ 3@ 4@
 
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@
         
        if 003B: 31@ == $PLAYER_ACTOR
        then continue
        end
         
        00A0: 31@ 6@ 7@ 8@
        0509: 5@ = distance_between_XY 2@ 3@ 6@ 7@
 
        if 5@ < 0@
        then
            0087: 0@ = 5@
            0085: 1@ = 31@
        end
    end
end
 
0AB2: ret 1 1@

just tested it and it worked, the message was sent successfully to the closest player after clicking the right mouse button. (tested with samp 0.3.7, cleo 4.1, sampfuncs 5.3.1)


btw you could check "shits.rar" from this thread; http://ugbase.eu/Thread-autoSay
There are mods called:
bind_arrest (activated by numpad +)
bind_cuff (activated by numpad -)
bind_rape (activated by numpad 7)
bind_rob (activated by numpad /)
bind_tazer (activated by numpad 9)

These mods use the following opcode instead of the ":GetClosestPed" function: "0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to 0@ closest_ped_to 1@"
This opcode potentially may cause some problems if there is no characters near you but I don't remember what exactly happened, either warnings or crash
 

kool

Active member
Joined
Jun 4, 2016
Messages
89
Reaction score
0
@monday nope,still doesn't work...

On one server it says " The player you're trying to PM is offline. "
On some " /pm id message "
Idk what is the problem if is it working for you... got everything ( SF 5.3.1,CLEO 4.1,SAMP 0.3.7 ).
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
DimicAmater said:
bump,any solution ?

Add in code this 0AF8: samp add_message_to_chat 1@ color 2@
then you see what cleo say when you do this...

this same like @Monday , but maybe work for you

[shcode=cpp]
{$CLEO .cs}
0000:
 
 
REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY 
 
 
WHILE TRUE
    WAIT 0   
IF
056D:   actor $PLAYER_ACTOR defined 
THEN
WAIT 0 
// GET ALL STREAMED PEDS     
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@
            IF AND
            803B:   31@ == $PLAYER_ACTOR  // (int)
            056D:   actor 31@ defined
            THEN
                0B2B: samp 0@ = get_player_id_by_actor_handle 31@
                00A0: store_actor $PLAYER_ACTOR position_to 1@ 2@ 3@
                00A0: store_actor 31@ position_to 4@ 5@ 6@
                0509: 7@ = distance_between_XY 1@ 2@ and_XY 4@ 5@
                IF
                7@ <= 0.3 /// IF player distance smaller or equals 0.3 then....
                THEN
                    IF
                    0AB0: 99 {NUMPAD 3}
                    THEN
                        say "/pm %d test" 0@
                        wait 1000
                    END    
                END
           END 
       END
   END
   END
END  
[/shcode]
 

kool

Active member
Joined
Jun 4, 2016
Messages
89
Reaction score
0
@Parazitas bro i downloaded CLEO 4.3 and puted in @monday 's code and when i press RMB it only PM one ID.






LwGdqZO.png
 

kool

Active member
Joined
Jun 4, 2016
Messages
89
Reaction score
0
@Parazitas

{$CLEO}
0000:

alloc 31@ 200

REPEAT
WAIT 0
UNTIL 0AFA:

WHILE TRUE
WAIT 0
IF AND
0AB0: 2
056D: actor $PLAYER_ACTOR defined
0B61: samp is_local_player_spawned
THEN
CALL @GetClosestPed 0 2@
IF 056D: actor 2@ defined
THEN
IF 0B2B: samp 3@ = get_player_id_by_actor_handle 2@
//THEN chatmsg "/pm %i test" -1 3@
THEN
format 31@ "/pm %i test" 3@
say 31@
wait 1000
END
END
END
END


:GetClosestPed
var
0@ : float
5@ : float
end
0@ = 600.0
1@ = -1

00A0: $PLAYER_ACTOR 2@ 3@ 4@

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@

if 003B: 31@ == $PLAYER_ACTOR
then continue
end

00A0: 31@ 6@ 7@ 8@
0509: 5@ = distance_between_XY 2@ 3@ 6@ 7@

if 5@ < 0@
then
0087: 0@ = 5@
0085: 1@ = 31@
end
end
end

0AB2: ret 1 1@
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,116
Solutions
5
Reaction score
882
Location
Lithuania
DimicAmater said:
@Parazitas

{$CLEO}
0000:

alloc 31@ 200

REPEAT
  WAIT 0
UNTIL 0AFA:

WHILE TRUE
WAIT 0
  IF AND
      0AB0: 2
      056D: actor $PLAYER_ACTOR defined
      0B61: samp is_local_player_spawned
  THEN
      CALL @GetClosestPed 0 2@      
      IF 056D: actor 2@ defined
      THEN
          IF 0B2B: samp 3@ = get_player_id_by_actor_handle 2@
          //THEN chatmsg "/pm %i test" -1 3@
          THEN
              format 31@ "/pm %i test" 3@
              say 31@
              wait 1000
          END
      END
  END
END


:GetClosestPed
var
0@ : float
5@ : float
end
0@ = 600.0
1@ = -1

00A0: $PLAYER_ACTOR 2@ 3@ 4@

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@
       
      if 003B: 31@ == $PLAYER_ACTOR
      then continue
      end
       
      00A0: 31@ 6@ 7@ 8@
      0509: 5@ = distance_between_XY 2@ 3@ 6@ 7@

      if 5@ < 0@
      then
          0087: 0@ = 5@
          0085: 1@ = 31@
      end
  end
end

0AB2: ret 1 1@

So code work for you?
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Set case converting to 'as is' from sanny builder options, you're probably have it set to uppercase, and it makes your script do /pm I test instead of an actual number.
 

kool

Active member
Joined
Jun 4, 2016
Messages
89
Reaction score
0
Working! @springfield thank you buddy.

Thanks to everyone who helped me,thank you soo much.

@monday @Parazitas @springfield
 
Status
Not open for further replies.
Top