{$CLEO .cs}
// ==============================================================================
// Project: SAMP Spawn Button Version Auto-Patcher
// Author: @mgmoldova
// Version: 1.0
// Date: 11/07/2026
// Desc: Automatic SA-MP version detection (R1-R5, DL)
// and patching SPAWN Buttons 0x31.
// Copyright: (c) 2026 mgmoldova. All rights reserved.
// ==============================================================================
NOP
const SAMP_EP_R1 = 0x31DF13
const SAMP_EP_R2 = 0x3195DD
const SAMP_EP_R3 = 0x0CC490
const SAMP_EP_R3_1 = 0x0CC4D0
const SAMP_EP_R4 = 0x0CBCB0
const SAMP_EP_R4_2 = 0x0CBCD0
const SAMP_EP_R5 = 0x0CBC90
const SAMP_EP_DL = 0x0FDB60
const PATCH_OFF_R1 = 0x714EF
const PATCH_OFF_R2 = 0x7158F
const PATCH_OFF_R3 = 0x753F7
const PATCH_OFF_R3_1 = 0x753F7
const PATCH_OFF_R4 = 0x75B37
const PATCH_OFF_R4_2 = 0x75B66
const PATCH_OFF_R5 = 0x75B06
const PATCH_OFF_DL = 0x75587
var
hSampModule: int
peOffset: int
entryPoint: int
patchOffset: int
patchAddress: int
end
repeat
wait 100
hSampModule = load_dynamic_library "samp.dll"
until hSampModule <> 0
peOffset = read_memory_with_offset hSampModule offset 0x3C size 4
peOffset += 0x28
entryPoint = read_memory_with_offset hSampModule offset peOffset size 4
switch entryPoint
case SAMP_EP_R1
patchOffset = PATCH_OFF_R1
case SAMP_EP_R2
patchOffset = PATCH_OFF_R2
case SAMP_EP_R3
patchOffset = PATCH_OFF_R3
case SAMP_EP_R3_1
patchOffset = PATCH_OFF_R3_1
case SAMP_EP_R4
patchOffset = PATCH_OFF_R4
case SAMP_EP_R4_2
patchOffset = PATCH_OFF_R4_2
case SAMP_EP_R5
patchOffset = PATCH_OFF_R5
case SAMP_EP_DL
patchOffset = PATCH_OFF_DL
default
patchOffset = 0
end
if patchOffset > 0
then
patchAddress = hSampModule + patchOffset
write_memory patchAddress size 1 value 0x31 virtual_protect true
end
free_dynamic_library hSampModule
terminate_this_custom_script