Kriso_Anderson
Active member
- Joined
- Apr 27, 2014
- Messages
- 56
- Reaction score
- 1
How to register command on 0.3.dl?
{$CLEO .cs}
0000:
wait 8500
if 8AA2: 0@ = load_library "samp.dll" // IF and SET
then 0A93: end_custom_thread
end
0AC6: 2@ = label @cmdname offset
0AC6: 5@ = label @cmdname2 offset
0AB1: call_scm_func @registerClientParam 0 _Return: CallBack 1@
0AB1: call_scm_func @registerClientCommand 3 dwSAMPHandle: 0@ szCommandName: 2@ CallBack: 1@
0AB1: call_scm_func @registerClientCommand 3 dwSAMPHandle: 0@ szCommandName: 5@ CallBack: 1@
while true
wait 0
if 31@ == 1
then
31@ = 0 /// Reset last cmd
0AB1: @GetLastCommandParams 0 _returnCMDParams 3@
0AD1: "%s" 2000 3@
end
end
:cmdname
hex
"mycmd1" 0
end
:cmdname2
hex
"mycmd2" 0
end
:registerClientParam
0AC6: 1@ = label @callback offset
// write 31@ address to assembly code
1@ += 2
0AC7: 3@ = var 31@ offset
0A8C: write_memory 1@ size 4 value 3@ virtual_protect 1
1@ -= 2
31@ = 0 // zeroing 31 var
0AB2: ret 1 1@
:registerClientCommand // unsigned long dwSAMPHandle, char szCommandName[], CMDPROC CallBack
0085: 3@ = 0@ // dwSAMPHandle
3@ += 0x2ACA14 // struct || SAMP_CHAT_INPUT_INFO_OFFSET
0A8D: 3@ = read_memory 3@ size 4 virtual_protect 1
0085: 4@ = 0@ // dwSAMPHandle
4@ += 0x691B0 // function || SAMP_FUNC_ADDCLIENTCMD
0AA6: call_method 4@ struct 3@ num_params 2 pop 0 2@ 1@
0AB2: ret 0
:callback
hex
83 35 11 11 11 11 01 // xor [11111111], 01
C3 // retn
end
:GetLastCommandParams
0AA2: 0@ = load_library "samp.dll"
0@ += 0x17FBB8 // SAMP CHAT OR DIALOG INPUT TEXT OFFSET || return like "/cmd BigWorld"
0AB1: @SkipCMD 1 StringPointer 0@ _Return 1@ // skip cmd and get "BigWorld"
0AB2: 1 1@
:SkipCMD
{
0AB1: @SkipCMD 1 StringPointer 5@ _Return 6@
}
0AB1: @strlen 1 string 0@ _return 31@
31@ -= 1
for 30@ = 0 to 31@
0A8D: 29@ = read_memory 0@ size 1 virtual_protect 1
if
29@ == 47 // 47 - /
then
0@++
0AB1: @strlen 1 string 0@ _return 28@
28@ -= 1
for 27@ = 0 to 28@
0A8D: 26@ = read_memory 0@ size 1 virtual_protect 1
if
26@ == 32 // 32 - space
then
0@++
0AB2: 1 0@
end
0@++
end
end
0@++
end
0AB2: 0
:strlen
{
Example: 0AB1: @strlen 1 string 1@ return: 3@
In: 0@ - text;
Out: 1@ - size;
}
for 1@ = 0 to 1024
0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0
if not 2@ == 0
jf break
0@ += 1
end
0AB2: ret 1 1@
/// Getting parameters (at 30 @ there will be a pointer to a string)
1@ += 9
0AC7: 3@ = var 30@ offset
0A8C: write_memory 1@ size 4 value 3@ virtual_protect 1
1@ -= 9
1@ += 15
0AC7: 3@ = var 31@ offset
0A8C: write_memory 1@ size 4 value 3@ virtual_protect 1
1@ -= 15
:callback
hex
51 // push ecx
56 // push esi
8B 74 24 0C // mov esi, [esp+0Ch]
89 34 25 11 11 11 11 // mov [11111111], esi
83 35 11 11 11 11 01 // xor [11111111], 01
5E // pop esi
59 // pop ecx
C3 // retn
end
Its works thanksThis is example - 0.3.DL .:
PHP:{$CLEO .cs} 0000: wait 8500 if 8AA2: 0@ = load_library "samp.dll" // IF and SET then 0A93: end_custom_thread end 0AC6: 2@ = label @cmdname offset 0AC6: 5@ = label @cmdname2 offset 0AB1: call_scm_func @registerClientParam 0 _Return: CallBack 1@ 0AB1: call_scm_func @registerClientCommand 3 dwSAMPHandle: 0@ szCommandName: 2@ CallBack: 1@ 0AB1: call_scm_func @registerClientCommand 3 dwSAMPHandle: 0@ szCommandName: 5@ CallBack: 1@ while true wait 0 if 31@ == 1 then 31@ = 0 /// Reset last cmd 0AB1: @GetLastCommandParams 0 _returnCMDParams 3@ 0AD1: "%s" 2000 3@ end end :cmdname hex "mycmd1" 0 end :cmdname2 hex "mycmd2" 0 end :registerClientParam 0AC6: 1@ = label @callback offset // write 31@ address to assembly code 1@ += 2 0AC7: 3@ = var 31@ offset 0A8C: write_memory 1@ size 4 value 3@ virtual_protect 1 1@ -= 2 31@ = 0 // zeroing 31 var 0AB2: ret 1 1@ :registerClientCommand // unsigned long dwSAMPHandle, char szCommandName[], CMDPROC CallBack 0085: 3@ = 0@ // dwSAMPHandle 3@ += 0x2ACA14 // struct || SAMP_CHAT_INPUT_INFO_OFFSET 0A8D: 3@ = read_memory 3@ size 4 virtual_protect 1 0085: 4@ = 0@ // dwSAMPHandle 4@ += 0x691B0 // function || SAMP_FUNC_ADDCLIENTCMD 0AA6: call_method 4@ struct 3@ num_params 2 pop 0 2@ 1@ 0AB2: ret 0 :callback hex 83 35 11 11 11 11 01 // xor [11111111], 01 C3 // retn end :GetLastCommandParams 0AA2: 0@ = load_library "samp.dll" 0@ += 0x17FBB8 // SAMP CHAT OR DIALOG INPUT TEXT OFFSET || return like "/cmd BigWorld" 0AB1: @SkipCMD 1 StringPointer 0@ _Return 1@ // skip cmd and get "BigWorld" 0AB2: 1 1@ :SkipCMD { 0AB1: @SkipCMD 1 StringPointer 5@ _Return 6@ } 0AB1: @strlen 1 string 0@ _return 31@ 31@ -= 1 for 30@ = 0 to 31@ 0A8D: 29@ = read_memory 0@ size 1 virtual_protect 1 if 29@ == 47 // 47 - / then 0@++ 0AB1: @strlen 1 string 0@ _return 28@ 28@ -= 1 for 27@ = 0 to 28@ 0A8D: 26@ = read_memory 0@ size 1 virtual_protect 1 if 26@ == 32 // 32 - space then 0@++ 0AB2: 1 0@ end 0@++ end end 0@++ end 0AB2: 0 :strlen { Example: 0AB1: @strlen 1 string 1@ return: 3@ In: 0@ - text; Out: 1@ - size; } for 1@ = 0 to 1024 0A8D: 2@ = read_memory 0@ size 1 virtual_protect 0 if not 2@ == 0 jf break 0@ += 1 end 0AB2: ret 1 1@