Jump to content

[CLEO] [SNIPPET] GetSAMPVersion ID / Name


Tupi
 Share

Recommended Posts

Prin următoarele snippet-uri puteți afla ID-ul / numele versiunii de SAMP pe care jucați.

Aceste două snippet-uri vă ajută atunci când vreți să restrictionați ca modul creat să funcționeze doar pe o anumita versiune de SAMP și nu numai.

 

 

Exemplu de mod:

{$CLEO}

0000:
repeat
wait 50
until 0AFA:

0AB1: @GetSAMPVersionID 0 0@ // call function to find out version id
0AB1: @GetSAMPVersionName 0 1@ // call function to find out version name
chatmsg "Your SAMP version is: %s[%d]" -1 1@ 0@

WHILE TRUE
WAIT 0
END

:GetSAMPVersionID
30@ = 0
if 0AA2: 31@ = load_library "samp.dll"
then
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1

    if 29@ == 0x5542F47A
    then 30@ = 1
    end
    
    if 29@ == 0x59C30C94
    then 30@ = 2
    end
    
    if 29@ == 0x5A6A3130
    then 30@ = 3
    end
    
    31@ -= 8
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1

    if 29@ == 0x5C0B4243
    then 30@ = 4
    end

    if 29@ == 0x5DD606CD
    then 30@ = 5
    end

    if 29@ == 0x6094ACAB
    then 30@ = 6
    end
end
0AB2: ret 1 30@

:GetSAMPVersionName
0AB1: @GetSAMPVersionID 0 _retID 30@
0AC8: 31@ = allocate_memory_size 30

if 30@ == 0
then 0AD3: 31@ = format "Not recognized"
end

if 30@ == 1
then 0AD3: 31@ = format "0.3.7 R1"
end

if 30@ == 2
then 0AD3: 31@ = format "0.3.7 R2"
end

if 30@ == 3
then 0AD3: 31@ = format "0.3.DL R1"
end

if 30@ == 4
then 0AD3: 31@ = format "0.3.7 R3 1"
end

if 30@ == 5
then 0AD3: 31@ = format "0.3.7 R4 1"
end

if 30@ == 6
then 0AD3: 31@ = format "0.3.7 R4 2"
end

0AB2: ret 1 31@

 

Snippets:

:GetSAMPVersionID
{
	USAGE: 0AB1: @GetSAMPVersionID 0 _retVersionID 0@
}
30@ = 0 // set id to 0 first
if 0AA2: 31@ = load_library "samp.dll" // load used library
then
    31@ += 0x128
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1

    if 29@ == 0x5542F47A // 0x5542F47A memory = 0.3.7 R1 version
    then 30@ = 1
    end
    
    if 29@ == 0x59C30C94 // 0x59C30C94 memory = 0.3.7 R2 version
    then 30@ = 2
    end
    
    if 29@ == 0x5A6A3130 // 0x5A6A3130 memory = 0.3.DL R1 version
    then 30@ = 3
    end
    
    31@ -= 8 // reading library samp.dll + 0x120
    0A8D: 29@ = read_memory 31@ size 4 virtual_protect 1

    if 29@ == 0x5C0B4243 // 0x5C0B4243 memory = 0.3.7 R3 1 version
    then 30@ = 4
    end

    if 29@ == 0x5DD606CD // 0x5DD606CD memory = 0.3.7 R4 1 version
    then 30@ = 5
    end

    if 29@ == 0x6094ACAB // 0x5C0B4243 memory = 0.3.7 R4 2 version
    then 30@ = 6
    end
end
0AA3: free_library 31@ // free used library
0AB2: ret 1 30@ // return version id
:GetSAMPVersionName
{
	USAGE: 0AB1: @GetSAMPVersionName 0 _retVersionName 0@
}
0AB1: @GetSAMPVersionID 0 _retVersionID 30@ // Get in 30@ version ID with first snippet
0AC8: 31@ = allocate_memory_size 30 // allocate for 31@ variable some memory for can format subsequent

if 30@ == 0
then 0AD3: 31@ = format "Not recognized" // if version ID is 0 then version name it cannot be returned
end

if 30@ == 1
then 0AD3: 31@ = format "0.3.7 R1"
end

if 30@ == 2
then 0AD3: 31@ = format "0.3.7 R2"
end

if 30@ == 3
then 0AD3: 31@ = format "0.3.DL R1"
end

if 30@ == 4
then 0AD3: 31@ = format "0.3.7 R3 1"
end

if 30@ == 5
then 0AD3: 31@ = format "0.3.7 R4 1"
end

if 30@ == 6
then 0AD3: 31@ = format "0.3.7 R4 2"
end

0AB2: ret 1 31@ // return version name formated above depending on the version id

 

Explicația:

În primul snippet se citesc anumite adrese de memorie din libraria samp.dll si in functie de fiecare adresa determinam versiunea atribuind un ID ulterior in functie de acel ID atribuit sa putem determina numele versiunii.

În cel de-al doilea snippet în funcție de ID-ul atribuit prin primul snippet alegem practic numele versiunii pentru a-l putea returna ulterior.

 

Original tutorial: CLICK

Edited by Tupi
Link to comment
Share on other sites

  • Tupi locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.