{$VERSION 3.1.0000}

thread 'MAIN'
var              
 $PLAYER_CHAR: Player 
end // var
01F0: set_max_wanted_level_to 6 
set_wb_check_to 0 
00C0: set_current_time 15 0 
04E4: unknown_refresh_game_renderer_at 824.0641 -1794.8955 
Camera.SetAtPos(2613.7415, 1122.9901, 10.8203)
$PLAYER_CHAR = Player.Create(#NULL, 2613.7415, 1122.9901, 10.8203)
$PLAYER_ACTOR = Actor.EmulateFromPlayer($PLAYER_CHAR)
07AF: $PLAYER_GROUP = player $PLAYER_CHAR group
Camera.SetBehindPlayer
set_weather 0          
wait 0 ms                                
$PLAYER_CHAR.SetClothes("PLAYER_FACE", "HEAD", Head)
$PLAYER_CHAR.SetClothes("JEANSDENIM", "JEANS", Legs)
$PLAYER_CHAR.SetClothes("SNEAKERBINCBLK", "SNEAKER", Shoes)
$PLAYER_CHAR.SetClothes("VEST", "VEST", Torso)
$PLAYER_CHAR.Build
$PLAYER_CHAR.CanMove = True
fade 1 (out) 0 ms                     
select_interior 0
0629: change_stat 181 (islands unlocked) to 4
016C: restart_if_wasted at 2027.77 -1420.52 15.99 angle 137.0 town_number 0
016D: restart_if_busted at 1550.68 -1675.49 14.51 angle 90.0 town_number 0
0180: set_on_mission_flag_to $ONMISSION // Note: your missions have to use the variable defined here ($ONMISSION)
03E6: remove_text_box

// ----------------------------------------------------------------------
//      New Interface Colors                                                                         
// ----------------------------------------------------------------------

0@ = 362035                // health bar
&0(0@,1i) = 0xFF00FFF0

0@ = 362036                // hud.money
&0(0@,1i) = 0xFF00FFF0

0@ = 362038                // SA fonts
&0(0@,1i) = 0xFF0C0CFF

0@ = 362039                // GTA3 fonts
&0(0@,1i) = 0xFF3BB847

0@ = 362040                // fonts.menubackground
&0(0@,1i) = 0xFFFF0000

0@ = 362041                // maplines
&0(0@,1i) = 0xFF00FFF0

// ----------------------------------------------------------------------
//      Show Debug menu                                                                         
// ----------------------------------------------------------------------

create_thread @RedefineKey
gosub @ChangeGXTEntries    // set custom text

$KEY_CONSOLE = 0x60 // DEFAULT_KEY ~
$CONSOLE_ENABLED = 1
4@ = 0      
while true
    wait 0            
    // toggle menu
    gosub @GetLastKey
    if
        003C: $KEY_CONSOLE == 2@
    then  
        &0(0@,1i) = 0
        if     
            $CONSOLE_ENABLED == 0
        then   
            $CONSOLE_ENABLED = 1
        else   
            $CONSOLE_ENABLED = 0    
        end 
    end
    03F0: text_draw_toggle $CONSOLE_ENABLED
    if
        $CONSOLE_ENABLED == 0
    then
        CONTINUE
    end         
    if
        $PLAYER_CHAR.Defined
        not Actor.Driving($PLAYER_ACTOR)        
    then
        // draw header
        gosub @TextDrawHeaderSettings 
        033E: text_draw 0 0 'FEC_DBG'   // Debug menu 

        // draw player pos
        gosub @TextDrawTextSettings
        033E: text_draw  0.0  12.0 'FED_DFL'  // "Player pos: "
        gosub @TextDrawText2Settings
        00A0: get_actor $PLAYER_ACTOR position_3D_coord_to 0@ 1@ 1@
        gosub @GetCoords 
        045B: text_draw_2numbers  8.0  24.0 'FED_DLS' 2@ 0@ // "X: ~1~.~1~, "
        gosub @TextDrawText2Settings
        00A0: get_actor $PLAYER_ACTOR position_3D_coord_to 1@ 0@ 1@
        gosub @GetCoords
        045B: text_draw_2numbers 8.0  36.0 'FED_DSR'  2@ 0@ // "Y: ~1~.~1~, "
        gosub @TextDrawText2Settings
        00A0: get_actor $PLAYER_ACTOR position_3D_coord_to 1@ 1@ 0@
        gosub @GetCoords
        045B: text_draw_2numbers 8.0  48.0 'FEC_TGD'  2@ 0@ // "Z: ~1~.~1~"
    
        // draw ped event
        gosub @TextDrawTextSettings
        080E: get_actor $PLAYER_ACTOR ped_event_to 0@   
        if
            0@ <> 0
        then
            0085: 4@ = 0@
        end
        045A: text_draw_1number 0 60.0 'FED_RID' 4@  // Current event: ~1~
        // draw target
        gosub @TextDrawTextSettings
        0@ = 300694
        008B: 0@ = &0(0@,1i)
        0@ += 1948
        0@ -= 0xA49960
        0@ /= 4
        008B: 0@ = &0(0@,1i)
        if
            0@ <> 0
        then 
            // get health, 0@ - actor ptr
            0085: 1@ = 0@ 
            1@ += 1344
            1@ -= 0xA49960
            1@ /= 4
    
            008C: 1@ = float_to_integer &0(1@,1i)
            033E: text_draw  0 72.0 'FED_SCP'  // Targeted CPed        
            gosub @TextDrawText2Settings
            045A: text_draw_1number 8.0 84.0 'DEBUGT1' 1@ // Target Health       
            0085: 1@ = 0@ 
            1@ += 0x22
            1@ -= 0xA49960
            1@ /= 4
            008B: 1@ = &0(1@,1i)
            div(1@, 0x10000)
            gosub @TextDrawText2Settings
            045A: text_draw_1number 8.0 96.0 'DEBW0' 1@ // Target Model
           
{
            // Traffic       
            gosub @TextDrawTextSettings
            0@ = 305869
            008B: 0@ = &0(0@,1i)
            0@ -= 0xA49954
            0@ /= 4
            045A: text_draw_1number 0.0 108.0 'DEBW1' &0(0@,1i)  // Traffic
}
            
        else
            033E: text_draw  0  72.0 'FED_SPR'  // no target        
        end        
    else
        $CONSOLE_ENABLED = 0 // disable menu if wasted_busted or driving
    end
end

// ----------------------------------------------------------------------
//          change GXT Entries
// ----------------------------------------------------------------------  
:ChangeGXTEntries  
  alloc($_param1, 76) 
  alloc($_asmproc, 77)
  alloc($_param2, 78)
  1@ = @_GXTNewString_1  
  2@ = @_GXTNewString_2
  3@ = @_GXTNewString_3
  4@ = @_GXTNewString_4     
  5@ = @_GXTNewString_5     
  6@ = @_GXTNewString_6     
  7@ = @_GXTNewString_7     
  8@ = @_GXTNewString_8  
  9@ = @_GXTNewString_9  
  10@ = @_GXTNewString_10  
  11@ = @_GXTNewString_11  
  0@ = -429863
  31@ = 1
  while 31@ < 22  // strings*2
      // -------------------------------
      // FIND GXT ENTRY
      // -------------------------------         
      &0(0@,1i) = 0xA49960
      &0(0@,1i) += @_GetGxtStringPointer
      $_asmproc = 0x6A0050               // char* GetGxtString
      $_param1 = 0xA49958
      005E: $_param1 += 1@(31@,33i)      // char* GXTEntry      
      0572: run_asm_inject true
      // -------------------------------
      // CHANGE GXT STRING
      // -------------------------------
      dec(31@)
      $_param1 = 0xA49964
      005E: $_param1 += 1@(31@,33i)     // char* Source, new string
      &0(0@,1i) = 0xA49960
      &0(0@,1i) += @_CopyString
      $_asmproc = 0x718660              // int CopyString
      0572: run_asm_inject true
      inc(31@,2)      
  end   
return
  // ASM injectors
  // -------------------------------  
  // .text:006A0050 ; char *__cdecl GetGxtString(char *GXT_Entry)
  :_GetGxtStringPointer
  hex 
   FF 35 909AA400      // push dword ptr [0xA49960+$_param1*4]
   B9    40B3C100      // mov ecx, @aAmericanGxt
   FF 15 949AA400      // call dword ptr [0xA49960+$_asmproc*4]
   A3    989AA400      // mov [$_param2], eax
   C3                  // return  
  end
  // .text:00718660 ; int __cdecl CopyString(char *Destination,char *Source)
  :_CopyString
  hex 
   FF 35 909AA400      // push dword ptr [0xA49960+$_param1*4]
   FF 35 989AA400      // push dword ptr [0xA49960+$_param2*4] 
   FF 15 949AA400      // call dword ptr [0xA49960+$_asmproc*4]
   83 C4 08            // add esp, 8
   C3                  // return  
  end                                                           
  // Compiled Strings Pool (null-terminated)
  // -------------------------------  
  :_GXTNewString_1
  0900: "Player position:"
  0900: 'FED_DFL'
  
  :_GXTNewString_2
  0900: "X: ~1~.~1~"
  0900: 'FED_DLS'

  :_GXTNewString_3  
  0900: "Y: ~1~.~1~"
  0900: 'FED_DSR'

  :_GXTNewString_4
  0900: "Z: ~1~.~1~"
  0900: 'FEC_TGD'
    
  :_GXTNewString_5
  0900: "Last eventID: ~1~"
  0900: 'FED_RID'

  :_GXTNewString_6
  0900: "Targeted ped:"
  0900: 'FED_SCP'

  :_GXTNewString_7
  0900: "<no target>"
  0900: 'FED_SPR'

  :_GXTNewString_8
  0900: "Health: ~1~"
  0900: 'DEBUGT1'

  :_GXTNewString_9
  0900: "Model: ~1~"
  0900: 'DEBW0'
   
  :_GXTNewString_10
  0900: "Press any ASCII key (numbers, letters)"
  0900: 'DEBW1'

  :_GXTNewString_11
  // last entry
    
// -------------------------------

// ----------------------------------------------------------------------
//   Text Draw Settings
// ----------------------------------------------------------------------

:TextDrawHeaderSettings
0343: set_text_draw_width_to 132.0
0345: set_text_draw_in_box 1
0348: set_text_draw_proportional 1 
033F: set_text_draw_letter_width_to 0.4 height_to 1.2 
0349: set_text_draw_style_to 2 
081C: draw_text_outline 1 0 0 0 200
0340: set_text_draw_color_RGB_mask_to 239 61 61 200
// draw background    
038E: draw_box position 0.0 0.0 width 270.0 height 400.0 color 255 128 0 alpha 170
// set box color RGBA (+ 17 next box)
0@ = 73384
&0(0@,1i) = 0x7FCCFFFF   
return

:TextDrawTextSettings
0348: set_text_draw_proportional 1 
033F: set_text_draw_letter_width_to 0.3 height_to 1.0 
0349: set_text_draw_style_to 1 
081C: draw_text_outline 1 255 128 0 255
0340: set_text_draw_color_RGB_mask_to 0 0 0 200
return

:TextDrawText2Settings
0348: set_text_draw_proportional 1 
033F: set_text_draw_letter_width_to 0.3 height_to 1.0 
0349: set_text_draw_style_to 1 
081C: draw_text_outline 0 0 0 0 0
0340: set_text_draw_color_RGB_mask_to 0 0 0 200
return

:GetCoords
008C: 2@ = float_to_integer 0@ // major num
008C: 1@ = float_to_integer 0@
1@ *= 1000
0@ *= 1000.0
008C: 0@ = float_to_integer 0@      
0062: 0@ -= 1@
0095: abs( 0@ ) 
return

:GetLastKey
0@ = -229908
008B: 1@ = &0(0@,1i)      // get last keypresses
0085: 2@ = 1@         
div(1@, 0x100)
mul(1@, 0x100)
0062: 2@ -= 1@
return


// ----------------------------------------------------------------------
//      To redefine the console key trigger
//      press P for 3 seconds, then press any key                                                                    
// ----------------------------------------------------------------------

:RedefineKey
while true
    wait 0            
    gosub @GetLastKey     
    if
        2@ == 0x50 // 'P'
    then
        // press P for 3 sec
        32@ = 0
        while 32@ < 3000 // 3 sec
            gosub @GetLastKey
            if
                2@ <> 0x50 // 'P'
            then
                jump @__exit            
            end
            wait 0
        end
        // clear keypress       
        &0(0@,1i) = 0       
        2@ = 0
        $CONSOLE_ENABLED = 0
        while 2@ == 0 // while not any key pressed
            00BC: show_text_highpriority 'DEBW1' time 300 1
            gosub @GetLastKey
            wait 0
        end        
        008A: $KEY_CONSOLE = 2@
        $CONSOLE_ENABLED = 1     
        :__exit
        &0(0@,1i) = 0 // clear keypress
        wait 1000
    end    
end

//-------------Mission 0---------------
// put your missions here
