Wait for samp to load

It's an alternative to this
Code:
repeat
wait 0
until 0AFA: is_samp_structures_available

Based on: https://github.com/Garret22/DX9Hook-SAMP/blob/master/src/DX9Hook/dllmain.cpp
This part exactly
C++:
while (!g_Chat)
{
    g_Chat = *(DWORD**)(g_dwSAMP_Addr + SAMP_CHAT_INFO_OFFSET);
    sleep(25);
}

Usage

Code:
{$CLEO .cs}
0000: NOP

0AB1: call_scm_func @wait_for_samp_to_load 0

0AD1: show_formatted_text_highpriority "Samp was loaded." time 5000
0A93: end_custom_thread

Functions to copy at the end of your script

Code:
:wait_for_samp_to_load
repeat
wait 0
//0AD1: show_formatted_text_highpriority "loading samp" 5000
until 0AA2: 31@ = load_library "samp.dll" // IF and SET
0085: 30@ = 31@ // (int)
30@ += 0xBABE
call @get_samp_version 1 addr_to_check 30@ _returned_version 29@  // 1 = 0.3.7 R1

if 30@ == 1
then
    31@ += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
    28@ = 0
    while 28@ == 0
    wait 0
        //0AD1: show_formatted_text_highpriority "reading SAMP_CHAT_INFO_OFFSET" 5000
        0A8D: 28@ = read_memory 31@ size 4 virtual_protect 4 
    end  
end

if 30@ == 0
then
// samp version not recognized
wait 15000
end

wait 1000
0AB2: ret 0

:get_samp_version
call @get_memcmp_address 0 _addr 31@
0AC6: 30@ = label @samp_0_3_7_R1_version_indicator offset
29@ = 1
0AA7: call_function 31@ num_params 3 pop 0 size 10 addr_2 30@ addr_1 0@ _returned 29@
if 29@ == 0
then
    //0AD1: show_formatted_text_highpriority "~G~Success: ~W~Samp version was recognized. It's 0.3.7 R1" time 5000
    0AB2: ret 1 1
end

{
0AC6: 30@ = label @samp_0_3_z_version_indicator offset
29@ = 1
0AA7: call_function 31@ num_params 3 pop 0 size 10 addr_2 30@ addr_1 0@ _returned 29@
if 29@ == 0
then
    //0AD1: show_formatted_text_highpriority "~G~Success: ~W~Samp version was recognized. It's 0.3z" time 5000
    0AB2: ret 1 2
end
}

0AD1: show_formatted_text_highpriority "~R~Error: ~W~Samp version was not recognized." time 5000
0AB2: ret 1 0

:get_memcmp_address
if 0AA2: 31@ = load_library "msvcrt.dll" // IF and SET
then
    if 0AA4: 30@ = get_proc_address "memcmp" library 31@ // IF and SET
    then
        0AB2: ret 1 30@
    end
end
0AB2: ret 1 0

:samp_0_3_7_R1_version_indicator
hex
F8 03 6A 00 40 50 51 8D 4C 24
end

{
I guess no one is using these so they're not implemented

:samp_0_3_z_version_indicator
hex
00 E8 00 00 85 D2 74 08 50 8B
end

:samp_0_3_z_version_indicator_2  // https://github.com/BinL3R/m0d-s0beit-sa-03z/blob/b34808cd432c22f24c5ff1319cbb5ea9210e5499/src/samp.cpp
hex
51 52 8D 8C 24 44 01 00 00 51
end

:samp_0_3_x_version_indicator
hex
8D 44 24 10 50 8D 4C 24 1C C7
end
}
 
Last edited:
Top