CLEO Help Why is this working with cleo 4.1 but it doesn't with cleo 4.3

CLEO related
Status
Not open for further replies.

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
Code:
:cmd_114
SAMP.IsCommandTyped(20@)
    if 056D: does_char_exist $PLAYER_ACTOR
    then
    0AB5: store_closest_entities $PLAYER_ACTOR vehicle_to 0@ ped_to 1@
        if 056D: does_char_exist 1@
        then
        0AB5: store_closest_entities 1@ vehicle_to 5@ ped_to 6@
            if 056E: does_vehicle_exist 5@
            then
            046C: 25@ = car 5@ driver
                if 056D: does_char_exist 25@
                then
                2@ = SAMP.GetSAMPPlayerIDByActorHandle(25@) 
                0AF9: samp say_msg "/repair %d 1" 2@
                end
            end
        end
    end
SAMP.CmdRet()

I made this command which works perfectly with cleo 4.1 but if i update to 4.3 and use the command again, nothing happens, the game doesn't crash or anything i'm guessing because of the 056D: opcode but i don't know why.

This command gets the closest driver to me and does "/repair <driver id> 1" on him. Can anyone suggest how to fix it for 4.3 or is there a better way to get the id of the closest car driver?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Why do you want to use CLEO 4.3?

The cause why its not working:
0AB5: store_closest_entities $PLAYER_ACTOR vehicle_to 0@ ped_to 1@
it's returning -1 -1.

dont ask me why, you can just create a function to get the closest player to you and it will work with 4.3 :imoverit:
 

Ravenous

Active member
Joined
Jan 21, 2016
Messages
61
Reaction score
4
Opcode.eXe link said:
Why do you want to use CLEO 4.3?

The cause why its not working:
0AB5: store_closest_entities $PLAYER_ACTOR vehicle_to 0@ ped_to 1@
it's returning -1 -1.

dont ask me why, you can just create a function to get the closest player to you and it will work with 4.3 :imoverit:

How would i go about getting the closest player to me? I could loop trough all the players check if they are in stream, get the distance between me and them but then what? I've been looking around and cleo doesn't have comparison operators like "<" or  ">". How to check which player is actually the closest?
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
here an example (not working code)
Code:
31@ = 300.0 // MAX_SEARCH_DISTANCE
30@ = -1 // actor
FOR 0@ = 0 TO 1000
    IF
    0B23:  samp is_player_connected 0@
    THEN
        IF
        0B20: samp 1@ = actor_handle_by_samp_player_id 0@
        THEN
            actor store pos player_actor
            actor storepos 1@
            bla = distancebetween player_actor and 1@
            if
            bla < 31@
            then
                30@ = 1@
                31@ = bla
            end
    
        END
    END
END
30@ = now closest actor
 

Spix

Well-known member
Joined
Sep 23, 2013
Messages
353
Reaction score
1
Opcode.eXe link said:
Why do you want to use CLEO 4.3?

The cause why its not working:
0AB5: store_closest_entities $PLAYER_ACTOR vehicle_to 0@ ped_to 1@
it's returning -1 -1.

dont ask me why, you can just create a function to get the closest player to you and it will work with 4.3 :imoverit:

If i change back to 4.1, What functions will i lose? (currently 4.3)
 
Status
Not open for further replies.
Top