CLEO SNIPPET Wait for samp to load

monday

Well-Known Member
Joined
Jun 23, 2014
Messages
1,043
Likes
75
Points
98
20
#1
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: [email protected] = load_library "samp.dll" // IF and SET
0085: [email protected] = [email protected] // (int)
[email protected] += 0xBABE
call @get_samp_version 1 addr_to_check [email protected] _returned_version [email protected]  // 1 = 0.3.7 R1

if [email protected] == 1
then
    [email protected] += 0x21A0E4 // SAMP_CHAT_INFO_OFFSET
    [email protected] = 0
    while [email protected] == 0
    wait 0
        //0AD1: show_formatted_text_highpriority "reading SAMP_CHAT_INFO_OFFSET" 5000
        0A8D: [email protected] = read_memory [email protected] size 4 virtual_protect 4 
    end  
end

if [email protected] == 0
then
// samp version not recognized
wait 15000
end

wait 1000
0AB2: ret 0

:get_samp_version
call @get_memcmp_address 0 _addr [email protected]
0AC6: [email protected] = label @samp_0_3_7_R1_version_indicator offset
[email protected] = 1
0AA7: call_function [email protected] num_params 3 pop 0 size 10 addr_2 [email protected] addr_1 [email protected] _returned [email protected]
if [email protected] == 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: [email protected] = label @samp_0_3_z_version_indicator offset
[email protected] = 1
0AA7: call_function [email protected] num_params 3 pop 0 size 10 addr_2 [email protected] addr_1 [email protected] _returned [email protected]
if [email protected] == 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: [email protected] = load_library "msvcrt.dll" // IF and SET
then
    if 0AA4: [email protected] = get_proc_address "memcmp" library [email protected] // IF and SET
    then
        0AB2: ret 1 [email protected]
    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