CLEO Help Getting the ID of the nearest player

CLEO related
Status
Not open for further replies.

fusro

Member
Joined
Sep 21, 2014
Messages
20
Reaction score
0
I noticed another thread about a CLEO keybinder and was wondering if there was a way to get the ID of the nearest player or your own ID and incorporate that in to the keybind.

For example, instead of having a CLEO keybind that does "/rob" one that does "/rob [ID of nearest player]"

Any help is appreciated. I am just learning to make CLEO scripts. Thanks.
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
Code:
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to $NOT_USED closest_ped_to 0@
if
056D:   actor 0@ defined
then
1@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
0AF9: "/rob %d" 1@
 

fusro

Member
Joined
Sep 21, 2014
Messages
20
Reaction score
0
Thank you both |]_ReT1neX_[| and TH3RM4L

I have tried the following but it results in a crash! Any pointers in the right direction?

Code:
{$CLEO}

:START
wait 0
IF AND
056D:   actor $PLAYER_ACTOR defined 
0AB0:   key_pressed 49 //key 1 to start the loop
then  
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to $NOT_USED closest_ped_to 0@
if
056D:   actor 0@ defined
then
1@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
0AF9: "/rob %d" 1@
END
END
 

ThermaL

Expert
Joined
Oct 23, 2013
Messages
1,593
Reaction score
3
{$CLEO}
0000: NOP

:MAIN
wait 0
if
0AB0: 49
jf @MAIN
0AB5: store_actor $PLAYER_ACTOR closest_vehicle_to $NOT_USED closest_ped_to 0@
if
056D:  actor 0@ defined
jf @MAIN
1@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
0AF9: "/rob %d" 1@

:STOP_UNTIL_RELEASING_BUTTON
wait 0
if
8AB0: 49
jf @STOP_UNTIL_RELEASING_BUTTON
goto @MAIN
 

Testnigga

New member
Joined
Jan 26, 2015
Messages
4
Reaction score
0

I copy and pasted you're cleo script exactly but still I get an error while compiling? it says Unknown number of Directives. Please help.
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
625
Reaction score
39
use this

Code:
:get_id_nearest_player
// FOR ALL PEDS
3@ = 1000.0 // Max. distance
4@ = 0xFFFFFF // Nearest player handle / id
 
0A8D: 0@ = read_memory 0xB74490 size 4 virtual_protect 0
0@ += 4
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
for 1@ = 0 to 35584 step 0x100
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    0@++
    if and
        2@ >= 0x00
        2@ < 0x80
    then
        005A: 2@ += 1@
        if or
            003C: $PLAYER_ACTOR == 2@ // LOCAL_PLAYER == REMOTE_PLAYER
            856D: NOT actor 2@ defined // REMOTE PLAYER IS NOT DEFINED
        then continue
        end
     
        0AB1: call @distanceBetweenActor 1 remote_player_handle 2@ retr_dist_to 5@
        if 0025: 3@ > 5@ // Max. dist > cur.
        then
            0087: 3@ = 5@ // Max. dist = cur.
            0085: 4@ = 2@ // Save remote player handle
        end
    end
end
 
if 4@ = SAMP.GetSAMPPlayerIDByActorHandle(4@)
then
    0485:  return_true
else
    059A:  return_false
end
0AB2: ret 2 3@ 4@
 
:distanceBetweenActor
Actor.StorePos(0@, 1@, 2@, 3@)
Actor.StorePos($PLAYER_ACTOR, 4@, 5@, 6@)
050A: 7@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 1@ 2@ 3@
0AB2: ret 1 7@

By legend2360
 

Hidend

Expert
Joined
Mar 4, 2013
Messages
625
Reaction score
39
{$CLEO .cs}
THREAD "ROB"

:START
wait 0
if 
0AB0:  key_pressed 49
jf @START
if
0AB1: call @get_id_nearest_player 0 retr_to fdist 0@ sid 1@
jf @START
0AF9: "/rob %d" 1@
wait 1000
jump @START

:get_id_nearest_player
// FOR ALL PEDS
3@ = 1000.0 // Max. distance
4@ = 0xFFFFFF // Nearest player handle / id

0A8D: 0@ = read_memory 0xB74490 size 4 virtual_protect 0
0@ += 4
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
for 1@ = 0 to 35584 step 0x100
    0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
    0@++
    if and
        2@ >= 0x00
        2@ < 0x80
    then
        005A: 2@ += 1@
        if or
            003C: $PLAYER_ACTOR == 2@ // LOCAL_PLAYER == REMOTE_PLAYER
            856D: NOT actor 2@ defined // REMOTE PLAYER IS NOT DEFINED
        then continue
        end
   
        0AB1: call @distanceBetweenActor 1 remote_player_handle 2@ retr_dist_to 5@
        if 0025: 3@ > 5@ // Max. dist > cur.
        then
            0087: 3@ = 5@ // Max. dist = cur.
            0085: 4@ = 2@ // Save remote player handle
        end
    end
end

if 4@ = SAMP.GetSAMPPlayerIDByActorHandle(4@)
then
    0485:  return_true
else
    059A:  return_false
end
0AB2: ret 2 3@ 4@

:distanceBetweenActor
Actor.StorePos(0@, 1@, 2@, 3@)
Actor.StorePos($PLAYER_ACTOR, 4@, 5@, 6@)
050A: 7@ = distance_between_XYZ 4@ 5@ 6@ and_XYZ 1@ 2@ 3@
0AB2: ret 1 7@
Im shit with cleo but need to work, anyway if don't work thermal or some pro will fix
That cleo is an edit from old [member=373]Monstercat[/member] cleo
 
Status
Not open for further replies.
Top