CLEO Help Grab player ID

CLEO related
Status
Not open for further replies.

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
How would I store a player's ID in a variable by simply clicking their skin/nametag?
 

downloadstuff

Active member
Joined
Apr 4, 2015
Messages
82
Reaction score
0
how do you want to click them? :c i can help you if you want to get their ID for example by aiming at them. but not by clicking o-o
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
downloadstuff link said:
how do you want to click them? :c i can help you if you want to get their ID for example by aiming at them. but not by clicking o-o

That would be good, but I mainly wanted it for when I'm spectating a player, so I can quickly /sk their ID with the nearest vehicle just by clicking them. I'm happy to write the rest of the code myself, but I couldn't find anything like this on Google.
 

Opcode.eXe

Expert
Joined
Feb 18, 2013
Messages
1,486
Reaction score
227
Location
( ͡° ͜ʖ ͡°)
Uhmm... like this.

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY



WHILE TRUE
    WAIT 0
    if
    0ab0: 1
    then
        repeat
            wait 0
        until 8ab0: 1
        if
        0AB1: @GET_CLOSEST_CURSOR_ACTOR 0 0@
        then
            0B2B: samp 2@ = get_player_id_by_actor_handle 0@
  
    
        end
    end
END


:GET_CLOSEST_CURSOR_ACTOR
28@ = 50.0 // distance from crosshair 
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
        056D:   actor 31@ defined
        then
            if
            803C:  $PLAYER_ACTOR == 31@ // (int)
            then
                04C4: store_coords_to 27@ 26@ 25@ from_actor 31@ with_offset 0.0 0.0 0.0
                068D: get_camera_position_to 24@ 23@ 22@
                if and
                02CB:   actor 31@ bounding_sphere_visible
                06BD:   no_obstacles_between 27@ 26@ 25@ and 24@ 23@ 22@ solid 1 car 0 actor 0 object 1 particle 0
                then
                    0AB1: @getScreenXYFrom3DCoords 3 3D_coords_X 27@ Y 26@ Z 25@ store_screen_X_to 24@ Y_to 23@   
                    
                    0B5E: get_cursor_pos 18@ 19@
                    0B5F: convert_window_screen_coords 18@ 19@ to game 18@ 19@

                    0509: 22@ = distance_between_XY 18@ 19@ and_XY 24@ 23@
                    if
                    0035:   28@ >= 22@ // (float)
                    then
                        0087: 28@ = 22@ // (float)
                        0087: 15@ = 31@ // (float)
                    end
               
               
                end     
            end
        end
    end
end
if
056D:   actor 15@ defined
then
    0485:  return_true
else
    059A:  return_false
end
0AB2: 1 15@
//0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
:getScreenXYFrom3DCoords
0AC7: 14@ = var 0@ offset
0AC7: 15@ = var 3@ offset
0AC7: 16@ = var 6@ offset
0AC7: 17@ = var 9@ offset
0AA5: call 0x70CE30 num_params 6 pop 6 {18@ 18@} 0 0 17@ 16@ 15@ 14@
0007: 12@ = 640.0
0007: 13@ = 448.0
0A8D: 14@ = read_memory 0xC17044 size 4 virtual_protect 0
0A8D: 15@ = read_memory 0xC17048 size 4 virtual_protect 0
0093: 14@ = integer 14@ to_float
0093: 15@ = integer 15@ to_float
0073: 12@ /= 14@
0073: 13@ /= 15@
006B: 3@ *= 12@
006B: 4@ *= 13@
0AB2: ret 2 3@ 4@
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
Opcode.eXe link said:
Uhmm... like this.

Code:
{$CLEO .cs}
0000:


REPEAT
    WAIT 0
UNTIL 0AFA:  SAMP_IS_READY



WHILE TRUE
    WAIT 0
    if
    0ab0: 1
    then
        repeat
            wait 0
        until 8ab0: 1
        if
        0AB1: @GET_CLOSEST_CURSOR_ACTOR 0 0@
        then
            0B2B: samp 2@ = get_player_id_by_actor_handle 0@
  
    
        end
    end
END


:GET_CLOSEST_CURSOR_ACTOR
28@ = 50.0 // distance from crosshair 
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
        056D:   actor 31@ defined
        then
            if
            803C:  $PLAYER_ACTOR == 31@ // (int)
            then
                04C4: store_coords_to 27@ 26@ 25@ from_actor 31@ with_offset 0.0 0.0 0.0
                068D: get_camera_position_to 24@ 23@ 22@
                if and
                02CB:   actor 31@ bounding_sphere_visible
                06BD:   no_obstacles_between 27@ 26@ 25@ and 24@ 23@ 22@ solid 1 car 0 actor 0 object 1 particle 0
                then
                    0AB1: @getScreenXYFrom3DCoords 3 3D_coords_X 27@ Y 26@ Z 25@ store_screen_X_to 24@ Y_to 23@   
                    
                    0B5E: get_cursor_pos 18@ 19@
                    0B5F: convert_window_screen_coords 18@ 19@ to game 18@ 19@

                    0509: 22@ = distance_between_XY 18@ 19@ and_XY 24@ 23@
                    if
                    0035:   28@ >= 22@ // (float)
                    then
                        0087: 28@ = 22@ // (float)
                        0087: 15@ = 31@ // (float)
                    end
               
               
                end     
            end
        end
    end
end
if
056D:   actor 15@ defined
then
    0485:  return_true
else
    059A:  return_false
end
0AB2: 1 15@
//0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
:getScreenXYFrom3DCoords
0AC7: 14@ = var 0@ offset
0AC7: 15@ = var 3@ offset
0AC7: 16@ = var 6@ offset
0AC7: 17@ = var 9@ offset
0AA5: call 0x70CE30 num_params 6 pop 6 {18@ 18@} 0 0 17@ 16@ 15@ 14@
0007: 12@ = 640.0
0007: 13@ = 448.0
0A8D: 14@ = read_memory 0xC17044 size 4 virtual_protect 0
0A8D: 15@ = read_memory 0xC17048 size 4 virtual_protect 0
0093: 14@ = integer 14@ to_float
0093: 15@ = integer 15@ to_float
0073: 12@ /= 14@
0073: 13@ /= 15@
006B: 3@ *= 12@
006B: 4@ *= 13@
0AB2: ret 2 3@ 4@

Thanks but I'm still clueless. Where's the player's ID variable stored?
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
Joey_ link said:
The playerid is stored in 2@

I realized after another look this morning, but what's wrong with my test script?
Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
thread "GETID" 

:GETID_11
wait 0 
   SAMP.Available
else_jump @GETID_11 

:GETID_24
wait 0 
if 
key_down 2 
else_jump @GETID_169 
jump @GETID_50 

:GETID_50
wait 0
if 
   not key_down 2 
else_jump @GETID_50 
if 
call @GETID_180 0 0@ 
else_jump @GETID_158 
2@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
say "/GO %D" 2@ 
jump @GETID_118 

:GETID_118
wait 0 
if 
key_down 46 
else_jump @GETID_158 
say "/GO %D" 2@ 
jump @GETID_24 

:GETID_158
wait 0 
jump @GETID_118 

:GETID_169
wait 0 
jump @GETID_24 

:GETID_180
28@ = 50.0 
0A8D: 29@ = read_memory 12010640 size 4 virtual_protect 0 
29@ += 4 
0A8D: 29@ = read_memory 29@ size 4 virtual_protect 0 
30@ = 0 

:GETID_230
0A8D: 31@ = read_memory 29@ size 1 virtual_protect 0 
29@ += 1 
if and
  31@ >= 0 
  128 > 31@ 
else_jump @GETID_503 
005A: 31@ += 30@ // (int) 
if 
056D:   actor 31@ defined 
else_jump @GETID_503 
if 
803C:   not  $PLAYER_ACTOR == 31@ // (int) 
else_jump @GETID_503 
04C4: store_coords_to 27@ 26@ 25@ from_actor 31@ with_offset 0.0 0.0 0.0 
068D: get_camera_position_to 24@ 23@ 22@ 
if and
02CB:   actor 31@ bounding_sphere_visible 
06BD:   no_obstacles_between 27@ 26@ 25@ and 24@ 23@ 22@ solid 1 car 0 actor 0 object 1 particle 0 
else_jump @GETID_503 
call @GETID_563 3 27@ 26@ 25@ 24@ 23@ 
0B5E: get_cursor_pos 18@ 19@ 
0B5F: convert_window_screen_coords 18@ 19@ to_game_screen_coords 18@ 19@ 
0509: 22@ = distance_between_XY 18@ 19@ and_XY 24@ 23@ 
if 
0035:   28@ >= 22@ // (float) 
else_jump @GETID_503 
0087: 28@ = 22@ // (float) 
0087: 15@ = 31@ // (float) 

:GETID_503
30@ += 256 
  30@ > 35584 
else_jump @GETID_230 
if 
056D:   actor 15@ defined 
else_jump @GETID_553 
return_true 
jump @GETID_555 

:GETID_553
return_false 

:GETID_555
ret 1 15@ 

:GETID_563
0AC7: 14@ = var 0@ offset 
0AC7: 15@ = var 3@ offset 
0AC7: 16@ = var 6@ offset 
0AC7: 17@ = var 9@ offset 
0AA5: call 7392816 num_params 6 pop 6 0 0 17@ 16@ 15@ 14@  
12@ = 640.0 
13@ = 448.0 
0A8D: 14@ = read_memory 12677188 size 4 virtual_protect 0 
0A8D: 15@ = read_memory 12677192 size 4 virtual_protect 0 
0093: 14@ = integer 14@ to_float 
0093: 15@ = integer 15@ to_float 
0073: 12@ /= 14@ // (float) 
0073: 13@ /= 15@ // (float) 
006B: 3@ *= 12@ // (float) 
006B: 4@ *= 13@ // (float) 
ret 2 3@ 4@

When I press the "del" key, it types /go, but with no ID. Same thing happens after aiming at a player. So the variable must be empty, or I've put it in the wrong place.
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
Ananas link said:
do you have the latest sampfuncs

Yeah, I have 5.3 as of today and still the variable is empty.

I also tried this as a different test:
Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
thread "GO" 

:GO_8
wait 0 
if and
0AD2: 0@ = player $PLAYER_CHAR targeted_actor //IF and SET 
key_down 49 
else_jump @GO_77 
2@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
say "/GO %D" 2@ 
chatmsg "ID = D%" 1046043 2@ 

:GO_77
wait 0 
jump @GO_8

This should work, but the variable stays empty. Response is "Go to 'PLAYER ID'" and in the chat "ID = D" with no number. What am I missing?
 

Joey_

Member
Joined
Apr 5, 2014
Messages
5
Reaction score
0
cuntstuble link said:
Yeah, I have 5.3 as of today and still the variable is empty.

I also tried this as a different test:
Code:
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP 
thread "GO" 

:GO_8
wait 0 
if and
0AD2: 0@ = player $PLAYER_CHAR targeted_actor //IF and SET 
key_down 49 
else_jump @GO_77 
2@ = SAMP.GetSAMPPlayerIDByActorHandle(0@)
say "/GO %D" 2@ 
chatmsg "ID = D%" 1046043 2@ 

:GO_77
wait 0 
jump @GO_8

This should work, but the variable stays empty. Response is "Go to 'PLAYER ID'" and in the chat "ID = D" with no number. What am I missing?


Try this: Credits go to Springfield.

Code:
{$CLEO .cs}

0000: NOP
thread "GO"

REPEAT
	WAIT 100
UNTIL  0AFA: is_samp_available

WHILE TRUE
	WAIT 0
	IF
		0AD2: 0@ = player $PLAYER_CHAR targeted_actor
	THEN
		0B2B: samp 1@ = get_player_id_by_actor_handle 0@ 

		IF
			0AB0: key_pressed 49
		THEN
			0AF9: samp say_msg "/go %i" 1@
			wait 500
		END
	END			
END
 

wavelengthzero

Active member
Joined
Feb 18, 2014
Messages
45
Reaction score
0
Joey_ link said:
Try this: Credits go to Springfield.

Code:
{$CLEO .cs}

0000: NOP
thread "GO"

REPEAT
	WAIT 100
UNTIL  0AFA: is_samp_available

WHILE TRUE
	WAIT 0
	IF
		0AD2: 0@ = player $PLAYER_CHAR targeted_actor
	THEN
		0B2B: samp 1@ = get_player_id_by_actor_handle 0@ 

		IF
			0AB0: key_pressed 49
		THEN
			0AF9: samp say_msg "/go %i" 1@
			wait 500
		END
	END			
END

Working. Thanks everyone, I just had to compile "AS IS" :imoverit:
 
Status
Not open for further replies.
Top