@halfastrc Yeap, It's possible:
Let's make a command at first for the dialog. (I'm gonna also do a way to open the dialog with the specific key, your opinion was F2).
0B34: samp register_client_command "locate" to_label @IDSET
:IDSET
SAMP.ShowDialog(1000, "{0070ba}Approach {FFFFFF}- {bdbdbd}Insert ID player", "" , "Set", "Exit", 1)
0B43: samp cmd_ret
0AB2: ret 0
The id of dialog is 1000, we'll gonna use the dialog id to define some function on it:
if 0B3C: samp is_dialog_responded id 1000 button 1@ list_item 0 input_text 0
then
//Some code
end
The first function of the dialog is, how to close the dialog?. (I decided to be: if the player pressed ESC, close the current dialog) :
if 0B3C: samp is_dialog_responded id 1000 button 1@ list_item 0 input_text 0
then
if 0AB0: is_key_pressed 27 //If user pressed ESC
then
0001: wait 10 ms
0B47: samp close_current_dialog_with_button 3@
end
end
Otherwise, go ahead and check the dialog edit box and save it as a string in my ini file.
if 0B3C: samp is_dialog_responded id 1000 button 1@ list_item 0 input_text 0
then
if 0AB0: is_key_pressed 27 //If user pressed ESC
then
0001: wait 10 ms
0B47: samp close_current_dialog_with_button 3@
else
if 1@ == 1 //If the select button pressed.
then
0AC8: 2@ = allocate_memory_size 100
0B4A: 2@ = get_current_dialog_editbox_text
0B47: samp close_current_dialog_with_button 3@
wait 100 //To avoid minor crashes
0AF5: write_string_to_ini_file 2@ path "CLEO\AHK.ini" section "Main" key "ID"
0AC9: free_allocated_memory 2@
end
end
end
Dialog functions have been done, now we have to work on binders and link 'em all to the ini file:
if and
0AB0: key_pressed 97 {NUM1}
8B21: not samp is_chat_opened //If user chat it's not open at all.
then
0AF9: samp say_msg "/approach"
end
Link:
if and
0AB0: key_pressed 97 {NUM1}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " " //If ini file were empty like this
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "/approach %s" 4@
wait 2000 //To avoid spam in chat
free 4@
end
end
same as Numpad 2 / 3:
if and
0AB0: key_pressed 98 {NUM2}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " " //If ini file were empty like this
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "/handcuff %s" 4@
wait 2000 //To avoid spam in chat
free 4@
end
end
if and
0AB0: key_pressed 99 {NUM3}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " " //If ini file were empty like this
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "/arrest %s" 4@
wait 2000 //To avoid spam in chat
free 4@
end
end
Binding dialog:
if and
8B21: samp is_chat_opened
8C7E: is_console_active
then
if 0AB0: is_key_pressed 113 //If user pressed F2
then
0AB1: call @IDSET 0
0001: wait 10 ms
end
end
The whole code should be like this:
{$CLEO .cs}
0000:
repeat
wait 0
until 0AFA:
if 8AF7: get_samp_base_to 0@
then
0A93: end_custom_thread
end
if 0AAB: file_exists "CLEO\AHK.ini"
then
0B34: samp register_client_command "locate" to_label @IDSET
else
wait 2000
chatmsg "Mod disabled, because you didn't put AHK file in your CLEO Folder." -1
0A93: end_custom_thread
end
repeat
wait 400
until 0AFA: is_samp_structures_available
WHILE TRUE
WAIT 0
if and
8B21: samp is_chat_opened
8C7E: is_console_active
then
if 0AB0: is_key_pressed 113 //If user pressed F2
then
0AB1: call @IDSET 0
0001: wait 10 ms
end
end
if 0B3C: samp is_dialog_responded id 1000 button 1@ list_item 0 input_text 0
then
if 0AB0: is_key_pressed 27 //If user pressed ESC
then
0001: wait 10 ms
0B47: samp close_current_dialog_with_button 3@
else
if 1@ == 1 //If the select button pressed.
then
0AC8: 2@ = allocate_memory_size 100
0B4A: 2@ = get_current_dialog_editbox_text
0B47: samp close_current_dialog_with_button 3@
wait 100 //To avoid minor crashes
0AF5: write_string_to_ini_file 2@ path "CLEO\AHK.ini" section "Main" key "ID"
0AC9: free_allocated_memory 2@
end
end
end
if and
0AB0: key_pressed 97 {NUM1}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " "
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "s /approach %s" 4@
free 4@
wait 2000 //To avoid spam in chat
end
end
if and
0AB0: key_pressed 98 {NUM2}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " "
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "s /handcuff %s" 4@
wait 2000 //To avoid spam in chat
free 4@
end
end
if and
0AB0: key_pressed 99 {NUM3}
8B21: not samp is_chat_opened
then
alloc 4@ 300
0AF4: 4@ = read_string_from_ini_file "CLEO\AHK.ini" section "Main" key "ID"
if 0C14: strcmp string1 4@ string2 " "
then
chatmsg "{FF0000}Error: {FFFFFF}there is no text exist in ini file." -1
wait 2000 //To avoid spam in chat
else
0AF9: samp say_msg "s /arrest %s" 4@
wait 2000 //To avoid spam in chat
free 4@
end
end
END //Looper
:IDSET
SAMP.ShowDialog(1000, "{0070ba}Approach {FFFFFF}- {bdbdbd}Insert ID player", "" , "Change", "Exit", 1)
0B43: samp cmd_ret
0AB2: ret 0
You have to make AHK.ini file otherwise the mod will be disabled automatically:
[Main]
ID=" "
If you still had a problem/help something like that. feel free.
EDIT:
Just realized I did something wrong with the /locate. this is the right function for this command. as you wanted
:IDSET
SAMP.IsCommandTyped(5@)
if
0AD4: 5@ = scan_string 5@ format "%d" 6@
else_jump @IDSET_FAIL
0AF1: write_int 6@ to "CLEO\AHK.ini" section "Main" key "ID"
jump @IDSET_DONE
:IDSET_FAIL
chatmsg "{FF0000}Error: {FFFFFF}Use /locate <id>" -1
:IDSET_DONE
0B43: samp cmd_ret
Advice: If you are interested, try to make a function that you are able to enable/disable the hotkey. that would be useful because sometimes maybe you intended to stop doing duty and get reset and chilling around. so the binders don't interface with your gameplay.