CLEO Help Server dialogs

CLEO related
Status
Not open for further replies.

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
Hello!
I would like to ask.. Is there any way how to open dialog on server if I know the dialog's ID? For example I know that ID of registration dialog is 1, so how can I open it?
I have already tried this code, which I made myself:

{$CLEO .cs}

thread 'DIALOG'

:Load
wait 30
if
  SAMP.Available
else_jump @Load
0B34: samp register_client_command "dialog" to_label @DIALOG
0B34: samp register_client_command "getid" to_label @GETID

while true
wait 0
end

:DIALOG
0B35: samp 0@ = get_last_command_params
if
0AD4: 1@ = scan_string 0@ format "%d %d" 2@ 3@
then
    0B86: dialog 2@ set_visible 3@ 
else
    0AF8: samp add_message_to_chat "/dialog <ID> <0/1>" color -1
end
SAMP.CmdRet

:GETID
0B4E: samp 1@ = get_current_dialog_id
alloc 29@ 64
format 29@ "ID of current dialog = %d" 1@ 
0AF8: samp add_message_to_chat 29@ -1
SAMP.CmdRet 

So at first, I used /getid when registration dialog was opened. I found out that it's ID is 1. After that I closed that dialog and I typed /dialog 1 1 (I wanted to open it using 0B86) and my game crashed.
Thank you for help guys..
 

pepeelpubero

Well-known member
Joined
Jan 21, 2014
Messages
433
Reaction score
1
I think you must close it with /dialog ID 0 (make it not visible) then if you type /dialog ID 1 (make it visible) then you make it visible, don't closing it with the close button.
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Setting it serversided will only send a rpc OnDialogRespond when you close the dialog with a button. And unless it's a pretty retarded server it will not do anything.
You can skip all this by just sending the rpc yourself, using;
0BC9: samp send_dialog_response dialog 0@ button 1@ listitem 2@ input 3@
 

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
springfield link said:
You can skip all this by just sending the rpc yourself, using;
0BC9: samp send_dialog_response dialog 0@ button 1@ listitem 2@ input 3@

So I made:
{$CLEO .cs}

thread 'DIALOGRESP'

:Load
wait 30
if
  SAMP.Available
else_jump @Load
0B34: samp register_client_command "dialogr" to_label @DIALOGRESP

while true
wait 0
end

:DIALOGRESP
0B35: samp 0@ = get_last_command_params
if
0AD4: 1@ = scan_string 0@ format "%d %d %d" 2@ 3@ 4@
then
    0BC9: samp send_dialog_response dialog 2@ button 4@ listitem 3@ input "" 
else
    0AF8: samp add_message_to_chat "/dialogr <ID> <listitem> <button>" color -1
end
SAMP.CmdRet

Help dialog ID = 108, I typed /dialogr 108 1 0 (dialog ID 108, listitem 1 - settings, button 0 - left button OK) and it crashed my game again.

18684651.png
 

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
No.. the problem isn't there.. I tried to remove all scripts and I left only "dialogr.cs" in my cleo directory. If you have some free time, could you make some code I can use for playing with server dialogs ? :D
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Your code works fine for me(CLEO 4.3/SF 5.1)
The only thing i might add would be
0B47: samp close_current_dialog_with_button 0
so the dialog interface actually closes.
 

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
1 more thing.. Could you explain me this opcode? 0B9D: dialog 1@ listbox 2@ element 3@ store_text_to 4@ data_to 5@
I don't know what listbox or element mean.
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
Those are for SF dialogs.
In SF dialogs you can make your own dialogs with lots of elements like checkboxes, sliders, buttons etc.
Each button/checkbox/slider can be created individualy so you can style your dialog however you want(adding 20 buttons where as samp based dialog can have only 2 etc.)
Listbox is the part of the samp base dialog which displays a box with elements, a list like in your previous picture.


0B9D: dialog 1@ listbox 2@ element 3@ store_text_to 4@ data_to 5@
1@ is the dialog handle, using 0B80
2@ is the listbox ID, using 0B99
3@ is the element, 0/1/2/3/4 etc
4@ is the text, the one you see in the dialog.
5@ is the data assigned to that element.

To use 0B9D first you need to insert elements.
0B9A: dialog 1@ listbox 1 insert_element "WEAPON m4" with_data 31 after -1 //-1 adds it as the last
 

DuFF

Member
Joined
Apr 5, 2014
Messages
20
Reaction score
0
Thank you..
I tried to use 0BC9 as you recommended, but it works just if the dialog I want to respond was opened before I typed /dialogr. So I'm asking: Is it any way how to open the dialog which wasn't opened before?
 
Status
Not open for further replies.
Top