CLEO Help nearest players

CLEO related
Status
Not open for further replies.

davidel

Well-known member
Joined
Jan 17, 2020
Messages
207
Reaction score
7
Location
Germania
Code:
{$CLEO}

0000:


alloc 31@ 200


REPEAT

WAIT 0

UNTIL 0AFA:



0B34: samp register_client_command "killc" to_label @cmd_mycmd



  0@ == TRUE

WHILE TRUE

WAIT 0

IF

056D: actor $PLAYER_ACTOR defined

0B61: samp is_local_player_spawned


CALL @GetClosestPed 0 2@

IF 056D: actor 2@ defined

THEN

wait 1000

say "/re"

END

END



:GetClosestPed

var

0@ : float

5@ : float

end

0@ = 10.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@


:cmd_mycmd

004E: end_thread

SAMP.CmdRet()

I have one problem with this. The problem is the cleo detect even the NPC as a player. Can someone please make this to detect only real players? please
 

Krc

Active member
Joined
Mar 30, 2018
Messages
193
Reaction score
25
Location
Lithuania
Code:
{$CLEO .cs}
0000: NOP
REPEAT
Wait 0
Until 0AFA: is_samp_structures_available

While True
Wait 0
if
056D: actor $PLAYER_ACTOR defined
then    
call @DISTANCE 1 distance_limit 6.0 _returnedActor 0@
if
056D: actor 0@ defined
then
// do stuff
end
end
END

:DISTANCE
var
0@ : float
5@ : float
end
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@
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Code:
{$CLEO}

0000:


alloc 31@ 200


REPEAT

WAIT 0

UNTIL 0AFA:



0B34: samp register_client_command "killc" to_label @cmd_mycmd



  0@ == TRUE

WHILE TRUE

WAIT 0

IF

056D: actor $PLAYER_ACTOR defined

0B61: samp is_local_player_spawned


CALL @GetClosestPed 0 2@

IF 056D: actor 2@ defined

THEN

wait 1000

say "/re"

END

END



:GetClosestPed

var

0@ : float

5@ : float

end

0@ = 10.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@


:cmd_mycmd

004E: end_thread

SAMP.CmdRet()

I have one problem with this. The problem is the cleo detect even the NPC as a player. Can someone please make this to detect only real players? please

I assume you have SAMPFUNCS, You can detect NPC and reject it on the ped search by adding this "conditional opcode" on your script:
Code:
0B64: samp is_player 0@ npc
8B64: not samp is_player 0@ npc
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,103
Solutions
5
Reaction score
882
Location
Lithuania
hmmmmmm
PHP:
{$CLEO .cs}

0000: NOP

repeat
wait 0
until 0AFA: 

while true
wait 0
    if
    056D: actor $PLAYER_ACTOR defined
    then    
        0AB1: @DISTANCE 1 distance_limit 6.0 _returnedActor 0@
        if and
        056D: actor 0@ defined
        8B64: samp not_player 0@ npc
        then
            // do stuff
        end
    end
end

:DISTANCE
var
0@ : float
5@ : float
end
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@
 

Edvincik

Well-known member
Joined
Mar 15, 2016
Messages
399
Reaction score
26
you can use this as well

0B2B: samp 1@ = get_player_id_by_actor_handle 0@
IF 0B23: samp is_player_connected 1@
 
Status
Not open for further replies.
Top