- 4,809
- 6,487
Сниплет позволяет вызывать локальные команды, которые были зарегистрированы сампом/скриптами/плагинами.
В данном коде переменная 0@ содержит название команды, а переменная 1@ содержит ее аргументы.
Код:
0AC8: 0@ = allocate_memory_size 33 // 33 - max cmd length
0AC8: 1@ = allocate_memory_size 144 // 144 - max chat input
0AD3: 0@ = format "fpslimit"
0AD3: 1@ = format "90"
0AB1: call @execLocalCommand 2 0@ 1@
0AC9: free_allocated_memory 1@
0AC9: free_allocated_memory 0@
Код:
:execLocalCommand // 0@ - pszCmdName 1@ - pszCmdArgs, no ret
0AB1: call @getCommandProc 1 0@ 2@
0AA7: call_function 2@ num_params 1 pop 1 1@
ret 0
Код:
:getCommandProc // 0@ - pszCmdName, ret - pCMD
/* getCmdProcByName
* R2: 0x65B40
* R1: 0x65A70
*/
0AA2: 1@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
1@ += 0x65B40
else
1@ += 0x65A70
end
0AB1: call @getInputInfo 0 2@
0AA8: call_function_method 1@ struct 2@ num_params 1 pop 0 0@ 3@
ret 1 3@
Код:
:getInputInfo // no args, ret - pInputInfo
/* InputInfo
* R2: 0x21A0F0
* R1: 0x21A0E8
*/
0AA2: 0@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
0@ += 0x21A0F0
else
0@ += 0x21A0E8
end
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0AB2: ret 1 0@
Код:
:is037R2 // no args, no ret
0AA2: 0@ = load_library "samp.dll"
0A8E: 1@ = 0@ + 0x129 // check SAMP version
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0
if 2@ == 0x0C
then
0AB2: ret 0 1
end
0AB2: ret 0 0
Код:
:execLocalCommand // 0@ - pszCmdName 1@ - pszCmdArgs, no ret
0AB1: call @getCommandProc 1 0@ 2@
0AA7: call_function 2@ num_params 1 pop 1 1@
ret 0
:getCommandProc // 0@ - pszCmdName, ret - pCMD
/* getCmdProcByName
* R2: 0x65B40
* R1: 0x65A70
*/
0AA2: 1@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
1@ += 0x65B40
else
1@ += 0x65A70
end
0AB1: call @getInputInfo 0 2@
0AA8: call_function_method 1@ struct 2@ num_params 1 pop 0 0@ 3@
ret 1 3@
:getInputInfo // no args, ret - pInputInfo
/* InputInfo
* R2: 0x21A0F0
* R1: 0x21A0E8
*/
0AA2: 0@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
0@ += 0x21A0F0
else
0@ += 0x21A0E8
end
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0AB2: ret 1 0@
:is037R2 // no args, no ret
0AA2: 0@ = load_library "samp.dll"
0A8E: 1@ = 0@ + 0x129 // check SAMP version
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0
if 2@ == 0x0C
then
0AB2: ret 0 1
end
0AB2: ret 0 0
Код:
{$CLEO}
wait 1750
0AC8: 0@ = allocate_memory_size 33 // 33 - max cmd length
0AC8: 1@ = allocate_memory_size 144 // 144 - max chat input
0AD3: 0@ = format "fpslimit"
0AD3: 1@ = format "90"
0AB1: call @execLocalCommand 2 0@ 1@
0AC9: free_allocated_memory 1@
0AC9: free_allocated_memory 0@
0A93: end_custom_thread
:execLocalCommand // 0@ - pszCmdName 1@ - pszCmdArgs, no ret
0AB1: call @getCommandProc 1 0@ 2@
0AA7: call_function 2@ num_params 1 pop 1 1@
ret 0
:getCommandProc // 0@ - pszCmdName, ret - pCMD
/* getCmdProcByName
* R2: 0x65B40
* R1: 0x65A70
*/
0AA2: 1@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
1@ += 0x65B40
else
1@ += 0x65A70
end
0AB1: call @getInputInfo 0 2@
0AA8: call_function_method 1@ struct 2@ num_params 1 pop 0 0@ 3@
ret 1 3@
:getInputInfo // no args, ret - pInputInfo
/* InputInfo
* R2: 0x21A0F0
* R1: 0x21A0E8
*/
0AA2: 0@ = load_library "samp.dll"
if 0AB1: call @is037R2 0
then
0@ += 0x21A0F0
else
0@ += 0x21A0E8
end
0A8D: 0@ = read_memory 0@ size 4 virtual_protect 0
0AB2: ret 1 0@
:is037R2 // no args, no ret
0AA2: 0@ = load_library "samp.dll"
0A8E: 1@ = 0@ + 0x129 // check SAMP version
0A8D: 2@ = read_memory 1@ size 1 virtual_protect 0
if 2@ == 0x0C
then
0AB2: ret 0 1
end
0AB2: ret 0 0