Help Nametag position snippet

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Example of how looks samp NickName and ID Drawing in samp with all calculation information samp 0.3.7 R1
C++:
void FUN_10070d40(void)

{
  int *piVar1;
  int iVar2;
  int **ppiVar3;
  int *piVar4;
  int iVar5;
  undefined4 uVar6;
  int iVar7;
  uint uVar8;
  float10 fVar9;
  float10 fVar10;
  undefined *puVar11;
  uint uVar12;
 
  if ((DAT_1021a0f8 != 0) && (*(char *)(*(int *)(DAT_1021a0f8 + 0x3c5) + 0x38) != '\0')) {
    FUN_100686a0();
    piVar1 = *(int **)(*(int *)(DAT_1021a0f8 + 0x3cd) + 0x18);
    puVar11 = &DAT_1012c8c8;
    FUN_10001010(&DAT_1012c8c8);
    FUN_1009a150(puVar11);
    iVar2 = *piVar1;
    uVar8 = 0;
    if (-1 < iVar2) {
      do {
        if ((((((ushort)uVar8 < 0x3ec) &&
              (*(int *)((int)piVar1 + (uVar8 & 0xffff) * 4 + 0xfde) == 1)) &&
             (ppiVar3 = *(int ***)((int)piVar1 + (uVar8 & 0xffff) * 4 + 0x2e),
             ppiVar3 != (int **)0x0)) &&
            ((piVar4 = *ppiVar3, piVar4 != (int *)0x0 && (*piVar4 != 0)))) &&
           ((*(char *)((int)piVar4 + 9) != '\0' &&
            ((*(int *)((int)piVar4 + 0xb3) != 0 &&
             (fVar9 = (float10)FUN_1009a7d0(),
             fVar10 = (float10)*(float *)(*(int *)(DAT_1021a0f8 + 0x3c5) + 0x27),
             fVar9 < fVar10 != (fVar9 == fVar10))))))) {
          if ((*(char *)((int)piVar4 + 9) == '\x13') &&
             ((piVar4[1] != 0 && (iVar5 = FUN_100b18b0(), iVar5 != 0)))) {
            FUN_1009a150(&DAT_1012c7c8);
            DAT_1012c90c = DAT_1012c7f8;
            DAT_1012c910 = DAT_1012c7fc;
            DAT_1012c914 = DAT_1012c800;
          }
          else {
            iVar5 = FUN_1009aa10();
            if (iVar5 == 0) goto LAB_10070f9b;
            DAT_1012c90c = 0.0;
            DAT_1012c910 = 0.0;
            DAT_1012c914 = 0.0;
            FUN_100a8d20(8,&DAT_1012c90c);
          }
          _DAT_1012c934 = DAT_1012c90c;
          _DAT_1012c938 = DAT_1012c910;
          _DAT_1012c93c = DAT_1012c914;
          iVar5 = FUN_10098320();
          iVar7 = 0;
          if (*(char *)(*(int *)(DAT_1021a0f8 + 0x3c5) + 0x2f) != '\0') {
            iVar7 = FUN_100abcd0(&DAT_100d8348,(double)_DAT_1012c934,(double)_DAT_1012c938,
                                 (double)_DAT_1012c93c,(double)*(float *)(iVar5 + 0xc),
                                 (double)*(float *)(iVar5 + 0x10),(double)*(float *)(iVar5 + 0x14) ,1
                                 ,0,0,1,0);
          }
          if ((*(char *)(*(int *)(DAT_1021a0f8 + 0x3c5) + 0x2f) == '\0') || (iVar7 != 0)) {
            uVar12 = uVar8;
            uVar6 = FUN_10013ce0(uVar8);
            _sprintf(&DAT_1012c848,"%s (%d)",uVar6,uVar12);
            if (*(int *)((int)piVar4 + 0xb) == 0) {
              uVar6 = FUN_10012ba0();
              fVar10 = (float10)FUN_1009a7d0(*(undefined *)(DAT_1021a0f8 + 0x224),uVar6);
              FUN_10012a00((float)fVar10);
              FUN_100686c0();
            }
          }
        }
LAB_10070f9b:
        uVar8 = uVar8 + 1;
      } while ((int)uVar8 <= iVar2);
    }
    FUN_100686b0();
  }
  return;
}
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
C++:
vector camera_posn; // game camera position
vector player_posn; // the position of the player you want to get the healthbar

float cam_distance = distance(camera_posn, player_posn)
player_posn = player->get_bone_position(BONE_HEAD); // BONE_HEAD = 8
player_posn.z += 0.2f + (cam_distance * 0.047499999f)
vector screen_posn = world_to_screen(player_posn)

draw_rectangle(screen_posn.x - 20.0f, screen_posn.y, 40.0f, 5.0f) // x, y, width, height
 

Kriso_Anderson

Active member
Joined
Apr 27, 2014
Messages
56
Reaction score
1
I tried with this
00A0: store_actor 30@ position_to 14@ 15@ 16@ //00A0: store_actor $PLAYER_ACTOR position_to 20@ 32@ 33@ 068D: get_camera_position_to 20@ 32@ 33@ 050A: 21@ = distance_between_XYZ 14@ 15@ 16@ and_XYZ 20@ 32@ 33@ 0013: 21@ *= 0.047499999 005B: 16@ += 21@ 16@ += 0.2 0B55: convert_3D_coords 14@ 15@ 16@ to_screen 22@ 23@ 0B6F: render font 10@ draw_text 11@ pos 22@ 23@ color 29@
but 0.047499999, is not correct when i am going to far, its just get to much z+, when i am close its z- to much
 
Joined
Feb 18, 2005
Messages
2,965
Reaction score
272
I tried with this
00A0: store_actor 30@ position_to 14@ 15@ 16@ //00A0: store_actor $PLAYER_ACTOR position_to 20@ 32@ 33@ 068D: get_camera_position_to 20@ 32@ 33@ 050A: 21@ = distance_between_XYZ 14@ 15@ 16@ and_XYZ 20@ 32@ 33@ 0013: 21@ *= 0.047499999 005B: 16@ += 21@ 16@ += 0.2 0B55: convert_3D_coords 14@ 15@ 16@ to_screen 22@ 23@ 0B6F: render font 10@ draw_text 11@ pos 22@ 23@ color 29@
but 0.047499999, is not correct when i am going to far, its just get to much z+, when i am close its z- to much

Oops, forgot about one important step, which is get the player bone head position, I've edited my previous post.
Here's a bare script test I did to make sure it kinda works, you need to add some checks to see if the player is on screen etc.


fa1OpsW.png


Code:
{$CLEO}

thread "shit"

repeat
wait 0
until SAMP.Available()

0B6D: render 20@ = create_font "Arial" height 10 flags 0x04

while true
wait 0
  068D: get_camera_position_to 10@ 11@ 12@
  for 0@ = 0 to 999
    0B20: samp 1@ = actor_handle_by_samp_player_id 0@
    if 056D: actor 1@ defined
    then
      00A0: store_actor 1@ position_to 2@ 3@ 4@

      0A96: 14@ = actor 1@ struct
      0AC7: 15@ = var 15@ offset
      0AA6: call_method 0x5E4280 struct 14@ num_params 3 pop 0 1 8 15@ // get bone position, 8 = BONE_HEAD
      
      050A: 21@ = distance_between_XYZ 10@ 11@ 12@ and_XYZ 2@ 3@ 4@
      0013: 21@ *= 0.047499999
      005B: 17@ += 21@
      17@ += 0.2
    
      0B25: samp 21@ = get_player_health 0@
      0AC8: 22@ = allocate_memory_size 260
      0AD3: 22@ = format "%d" 21@
      
      0B55: convert_3D_coords 15@ 16@ 17@ to_screen 18@ 19@
      18@ -= 50
      19@ += 15
      0B6F: render font 20@ draw_text 22@ pos 18@ 19@ color -1
      
      0AC9: 22@
    end
  end               
end

Tell me, do you want them to throw out your garbage and clean your house for free? Let's get help with the code, they don't do what you ask, pay money, maybe something, I'll take the job

Brother, chill, it's just some simple question, there's no need for such a harsh reply.
 

SobFoX

Expert
Joined
Jul 14, 2015
Messages
1,463
Solutions
5
Reaction score
916
Location
Israel
Oops, forgot about one important step, which is get the player bone head position, I've edited my previous post.
Here's a bare script test I did to make sure it kinda works, you need to add some checks to see if the player is on screen etc.


fa1OpsW.png


Code:
{$CLEO}

thread "shit"

repeat
wait 0
until SAMP.Available()

0B6D: render 20@ = create_font "Arial" height 10 flags 0x04

while true
wait 0
  068D: get_camera_position_to 10@ 11@ 12@
  for 0@ = 0 to 999
    0B20: samp 1@ = actor_handle_by_samp_player_id 0@
    if 056D: actor 1@ defined
    then
      00A0: store_actor 1@ position_to 2@ 3@ 4@

      0A96: 14@ = actor 1@ struct
      0AC7: 15@ = var 15@ offset
      0AA6: call_method 0x5E4280 struct 14@ num_params 3 pop 0 1 8 15@ // get bone position, 8 = BONE_HEAD
     
      050A: 21@ = distance_between_XYZ 10@ 11@ 12@ and_XYZ 2@ 3@ 4@
      0013: 21@ *= 0.047499999
      005B: 17@ += 21@
      17@ += 0.2
   
      0B25: samp 21@ = get_player_health 0@
      0AC8: 22@ = allocate_memory_size 260
      0AD3: 22@ = format "%d" 21@
     
      0B55: convert_3D_coords 15@ 16@ 17@ to_screen 18@ 19@
      18@ -= 50
      19@ += 15
      0B6F: render font 20@ draw_text 22@ pos 18@ 19@ color -1
     
      0AC9: 22@
    end
  end              
end



Brother, chill, it's just some simple question, there's no need for such a harsh reply.
It's easy for you to say you don't answer hundreds of these, but it's still nice to see you again after a long time ;)
 

Kriso_Anderson

Active member
Joined
Apr 27, 2014
Messages
56
Reaction score
1
Oops, forgot about one important step, which is get the player bone head position, I've edited my previous post.
Here's a bare script test I did to make sure it kinda works, you need to add some checks to see if the player is on screen etc.


fa1OpsW.png


Code:
{$CLEO}

thread "shit"

repeat
wait 0
until SAMP.Available()

0B6D: render 20@ = create_font "Arial" height 10 flags 0x04

while true
wait 0
  068D: get_camera_position_to 10@ 11@ 12@
  for 0@ = 0 to 999
    0B20: samp 1@ = actor_handle_by_samp_player_id 0@
    if 056D: actor 1@ defined
    then
      00A0: store_actor 1@ position_to 2@ 3@ 4@

      0A96: 14@ = actor 1@ struct
      0AC7: 15@ = var 15@ offset
      0AA6: call_method 0x5E4280 struct 14@ num_params 3 pop 0 1 8 15@ // get bone position, 8 = BONE_HEAD
     
      050A: 21@ = distance_between_XYZ 10@ 11@ 12@ and_XYZ 2@ 3@ 4@
      0013: 21@ *= 0.047499999
      005B: 17@ += 21@
      17@ += 0.2
   
      0B25: samp 21@ = get_player_health 0@
      0AC8: 22@ = allocate_memory_size 260
      0AD3: 22@ = format "%d" 21@
     
      0B55: convert_3D_coords 15@ 16@ 17@ to_screen 18@ 19@
      18@ -= 50
      19@ += 15
      0B6F: render font 20@ draw_text 22@ pos 18@ 19@ color -1
     
      0AC9: 22@
    end
  end              
end



Brother, chill, it's just some simple question, there's no need for such a harsh reply.
Thank you very much, its working, you always helping me <3
 
Top