[font=Tahoma,Verdana,Arial,Sans-Serif]I'm trying to convert screen cords (textdraw position cords) to 3d cords so I can call @AIM_AT_POS but is giving me some weird value and Idk why[/font]
yea it should aim at the same position I m looking(TEST 2 TEXTDRAW = CROSSHAIR POS) at but what I want to do is to compare that position to closest ped position so I can +/- camera_offset until I m aiming at that fkin ped
[shcode=cpp]
{$CLEO}
0000:
while true
wait 0
if key_down 0x02
then
if 0AB1: @GET_TARGET_ACTOR 0 30@
then
04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset 0.0 0.0 0.0
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 1@ Y 2@ Z 3@ store_screen_X_to 4@ Y_to 5@
0C48: samp textdraw 50 create "TEST 1" pos 4@ 5@
GOSUB @GET_AIMING_POS
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
0C48: samp textdraw 51 create "TEST 2" pos 3@ 4@
0B8F: convert_screen_coords 3@ 4@ depth 1 to_world_3d 1@ 2@ 3@
if key_down 0x01
then
0AB1: @AIM_AT_POS 4 XYZ: 1@ 2@ 3@ ADD_CAMERA_OFFSET 0.04632
end
end
else
if 0C5D: samp textdraw 50 is_exists
then 0C5E: samp textdraw 50 delete
end
end
end
:AIM_AT_POS
0087: 8@ = 3@
068D: get_camera_position_to 3@ 4@ 5@
0063: 0@ -= 3@
0063: 1@ -= 4@
0604: get_Z_angle_for_point 0@ 1@ store_to 6@
6@ -= 90.0
0017: 6@ /= 57.2957795
005B: 6@ += 8@ // (float)
0A8D: 7@ = read_memory 0xB6F248 size 4 virtual_protect 0
0A25: set_camera_on_players_X_angle 7@ Z_angle 6@
0AB2: 0
:GET_TARGET_ACTOR
28@ = 640.0
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@
if 02D8: actor $PLAYER_ACTOR current_weapon == 33
then
0509: 22@ = distance_between_XY 330.0 190.0 and_XY 24@ 23@
else
if or
02D8: actor $PLAYER_ACTOR current_weapon == 31
02D8: actor $PLAYER_ACTOR current_weapon == 24
then 0509: 22@ = distance_between_XY 339.0 179.0 and_XY 24@ 23@
else
if 02D8: actor $PLAYER_ACTOR current_weapon == 34
then 0509: 22@ = distance_between_XY 316.0 228.0 and_XY 24@ 23@
end
end
end
if
0035: 28@ >= 22@ // (float)
then
0087: 28@ = 22@ // (float)
0087: 15@ = 31@ // (float)
12@ = 1337
end
end
end
end
end
end
if 12@ == 1337
then
12@ = 0
if 056D: actor 15@ defined
then
0485: return_true
else
059A: return_false
end
end
0AB2: 1 15@
:GET_AIMING_POS // PASTE THIS AT THE END OF THE SCRIPT
Actor.StorePos($PLAYER_ACTOR, 1@, 2@, 3@)
0A9F: 5@ = current_thread_pointer
5@ += 80
0A8E: 6@ = 5@ + 12 // int
0AA6: call_method 5327216 11989032 num_params 6 pop 0 6@ 5@ 3@ 2@ 1@ 4@
if
86BD: not no_obstacles_between 1@ 2@ 3@ and 8@ 9@ 10@ solid 1 car 1 actor 0 object 1 particle 0
else_jump @ADD
jump @END_POS
:ADD
4@ += 1.0
if
4@ > 250.0
else_jump @GET_AIMING_POS
:END_POS
0@ = 0.0
1@ = 0.0
2@ = 0.0
005B: 0@ += 8@ // (float)
005B: 1@ += 9@ // (float)
005B: 2@ += 10@ // (float)
4@ = 0.0 // RESET THE AIM RADIUS
return
: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@
[/shcode]
yea it should aim at the same position I m looking(TEST 2 TEXTDRAW = CROSSHAIR POS) at but what I want to do is to compare that position to closest ped position so I can +/- camera_offset until I m aiming at that fkin ped
[shcode=cpp]
{$CLEO}
0000:
while true
wait 0
if key_down 0x02
then
if 0AB1: @GET_TARGET_ACTOR 0 30@
then
04C4: store_coords_to 1@ 2@ 3@ from_actor 30@ with_offset 0.0 0.0 0.0
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 1@ Y 2@ Z 3@ store_screen_X_to 4@ Y_to 5@
0C48: samp textdraw 50 create "TEST 1" pos 4@ 5@
GOSUB @GET_AIMING_POS
0AB1: call_scm_func @getScreenXYFrom3DCoords 3 3D_coords_X 0@ Y 1@ Z 2@ store_screen_X_to 3@ Y_to 4@
0C48: samp textdraw 51 create "TEST 2" pos 3@ 4@
0B8F: convert_screen_coords 3@ 4@ depth 1 to_world_3d 1@ 2@ 3@
if key_down 0x01
then
0AB1: @AIM_AT_POS 4 XYZ: 1@ 2@ 3@ ADD_CAMERA_OFFSET 0.04632
end
end
else
if 0C5D: samp textdraw 50 is_exists
then 0C5E: samp textdraw 50 delete
end
end
end
:AIM_AT_POS
0087: 8@ = 3@
068D: get_camera_position_to 3@ 4@ 5@
0063: 0@ -= 3@
0063: 1@ -= 4@
0604: get_Z_angle_for_point 0@ 1@ store_to 6@
6@ -= 90.0
0017: 6@ /= 57.2957795
005B: 6@ += 8@ // (float)
0A8D: 7@ = read_memory 0xB6F248 size 4 virtual_protect 0
0A25: set_camera_on_players_X_angle 7@ Z_angle 6@
0AB2: 0
:GET_TARGET_ACTOR
28@ = 640.0
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@
if 02D8: actor $PLAYER_ACTOR current_weapon == 33
then
0509: 22@ = distance_between_XY 330.0 190.0 and_XY 24@ 23@
else
if or
02D8: actor $PLAYER_ACTOR current_weapon == 31
02D8: actor $PLAYER_ACTOR current_weapon == 24
then 0509: 22@ = distance_between_XY 339.0 179.0 and_XY 24@ 23@
else
if 02D8: actor $PLAYER_ACTOR current_weapon == 34
then 0509: 22@ = distance_between_XY 316.0 228.0 and_XY 24@ 23@
end
end
end
if
0035: 28@ >= 22@ // (float)
then
0087: 28@ = 22@ // (float)
0087: 15@ = 31@ // (float)
12@ = 1337
end
end
end
end
end
end
if 12@ == 1337
then
12@ = 0
if 056D: actor 15@ defined
then
0485: return_true
else
059A: return_false
end
end
0AB2: 1 15@
:GET_AIMING_POS // PASTE THIS AT THE END OF THE SCRIPT
Actor.StorePos($PLAYER_ACTOR, 1@, 2@, 3@)
0A9F: 5@ = current_thread_pointer
5@ += 80
0A8E: 6@ = 5@ + 12 // int
0AA6: call_method 5327216 11989032 num_params 6 pop 0 6@ 5@ 3@ 2@ 1@ 4@
if
86BD: not no_obstacles_between 1@ 2@ 3@ and 8@ 9@ 10@ solid 1 car 1 actor 0 object 1 particle 0
else_jump @ADD
jump @END_POS
:ADD
4@ += 1.0
if
4@ > 250.0
else_jump @GET_AIMING_POS
:END_POS
0@ = 0.0
1@ = 0.0
2@ = 0.0
005B: 0@ += 8@ // (float)
005B: 1@ += 9@ // (float)
005B: 2@ += 10@ // (float)
4@ = 0.0 // RESET THE AIM RADIUS
return
: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@
[/shcode]