Jump to content

[CLEO] / [HELP] Dialog.Create


D J C
 Share

Recommended Posts

I just decided to work on this one first. But it seems like a very difficult thing to me and it really confuses me a bit.

Can you give me the necessary explanations with a simple code and explanations?

 

If you can. Create a dialogue. The dialog has 2 buttons and 3 options: Ex: Option one | Option two | Option three

And when I select the button this code should work: 0AF9: samp say_msg "I pressed the X Option".

 

image.png.6de568e38c1d073d0730aafc54125c76.png

Link to comment
Share on other sites

image.png.a139e648dd275f5dcd34b3374db582e6.png

Now, Where is these highlights came from ? It's related with positions or somewhat like that ?

 

I wrote something now, and it actually failed, (Game has been slow-motion and black screens)

{$CLEO}

0000:

repeat
    wait 0
until 0AFA:

gosub @Dialog

0B34: "test" to @test
0B34: "reset" to @reset

while true
    wait 0
 
if Dialog.IsVisible(0@)
    then
        if 0C89:  key_just_pressed 0x1B
        then
            if Dialog.IsVisible(0@)
            then 
                Dialog.SetVisible(0@, 0)
                0B8D: samp set_cursor_mode 0
            end
        end
        
        if Dialog.IsVisible(0@)
        then 0B8D: samp set_cursor_mode 2
        end    
        
END

:Dialog
Dialog.Create(0@, "Test")
SAMP.GetScreenResolution(1@, 2@)
1@ /= 2
2@ /= 2 
1@ -= 100
2@ -= 100
Dialog.SetRECT(0@, 1@, 2@, 469, 410)
Dialog.AddListBox(0@, 0, 3, 3, 460, 340)
Dialog.AddButton(0@, 1, "Exit", 283, 350, 150, 35)
Dialog.AddButton(0@, 2, "Select", 33, 350, 150, 35)
Dialog.SetVisible(0@, False)
return 

:test
gosub @Dialog
Dialog.SetVisible(0@, 1)
cmdret 

:reset
0A92: create_custom_thread "test.cs"
0A93: end_custom_thread
0ACD: show_text_highpriority "reloaded" time 1337
SAMP.CmdRet()

But it seems like the main problem is from the Loop, (While true).

Link to comment
Share on other sites

Hello,

 

I give you an exemple of mod, from here you manage to adapt it to your liking

 

{$CLEO}

0000:
repeat
wait 0
until 0AFA:

gosub @CreateDialog
0B34: "showdialog" @ShowDialog
0B34: "hidedialog" @HideDialog

WHILE TRUE
WAIT 0

if Dialog.IsVisible(0@)
then
        SAMP.SetCursorMode(2)

        if Dialog.PopEvent(0@, 3@, 4@)  //4@ - buton id
        then
                if 4@ == 1
                then
                        say "You clicked on button 1"
                end
			
                 if 4@ == 2
                 then
                         say "You clicked on button 2"
                 end

                 if 4@ == 3
                 then
                         say "You clicked on button 3"
                 end
         end
end

END

:CreateDialog
Dialog.Create(0@, "DialogTitle")
SAMP.GetScreenResolution(1@, 2@)
1@ /= 2
2@ /= 2 
1@ -= 100
2@ -= 100
Dialog.SetRECT(0@, 1@, 2@, 469, 410)
Dialog.AddListBox(0@, 0, 3, 3, 460, 340)
Dialog.AddButton(0@, 1, "Button1", 33, 350, 150, 35)
Dialog.AddButton(0@, 2, "Button2", 150, 350, 150, 35)
Dialog.AddButton(0@, 3, "Button3", 350, 350, 150, 35)
Dialog.SetVisible(0@, False)
SAMP.CmdRet

:ShowDialog
Dialog.SetVisible(0@, True)
SAMP.CmdRet

:HideDialog
Dialog.SetVisible(0@, False)
SAMP.SetCursorMode(0)
SAMP.CmdRet

 

It is more complicated to make 2 buttons with 3 options, the easiest is to make a button for each option.

Edited by Tupi
Link to comment
Share on other sites

13 minutes ago, Tupi said:

Hello,

 

I give you an exemple of mod, from here you manage to adapt it to your liking

 


{$CLEO}

0000:
reapat
wait 0
until 0AFA:

gosub @CreateDialog
0B34: "showdialog" @ShowDialog
0B34: "hidedialog" @HideDialog

WHILE TRUE
WAIT 0

if Dialog.IsVisible(0@)
then
		SAMP.SetCursorMode(2)

        if Dialog.PopEvent(0@, 3@, 4@)
        then
                if 4@ == 1
                then
                        say "You clicked on button 1"
                end
			
                 if 4@ == 2
                 then
                         say "You clicked on button 2"
                 end

                 if 4@ == 3
                 then
                         say "You clicked on button 3"
                 end
         end
end

END

:CreateDialog
Dialog.Create(0@, "DialogTitle")
SAMP.GetScreenResolution(1@, 2@)
1@ /= 2
2@ /= 2 
1@ -= 100
2@ -= 100
Dialog.SetRECT(0@, 1@, 2@, 469, 410)
Dialog.AddListBox(0@, 0, 3, 3, 460, 340)
Dialog.AddButton(0@, 1, "Button1", 33, 350, 150, 35)
Dialog.AddButton(0@, 2, "Button2", 150, 350, 150, 35)
Dialog.AddButton(0@, 3, "Button3", 350, 350, 150, 35)
Dialog.SetVisible(0@, False)
SAMP.CmdRet

:ShowDialog
Dialog.SetVisible(0@, True)
SAMP.CmdRet

:HideDialog
Dialog.SetVisible(0@, False)
SAMP.SetCursorMode(0)
SAMP.CmdRet

 

The script has a problem. The game screen sometimes turns black and returns to original state + Fps drop.

Link to comment
Share on other sites

2 minutes ago, D J C said:

The script has a problem. The game screen sometimes turns black and returns to original state + Fps drop.

Use "repeat" not "reapat', my mistake, sorry.

Link to comment
Share on other sites

4 minutes ago, Tupi said:

Use "repeat" not "reapat', my mistake, sorry.

Neah I actually fixed that:

 

{$CLEO}

0000:

repeat
    wait 0
until 0AFA:

gosub @CreateDialog
0B34: "showdialog" @ShowDialog
0B34: "hidedialog" @HideDialog

WHILE TRUE
WAIT 0
  
  .........

 

But still I had the same Issue.

 

BTW, Also when I run the game. The dialogue opens automatically without me doing anything

Edited by D J C
Link to comment
Share on other sites

1 minute ago, D J C said:

Neah I actually fixed that:

 


{$CLEO}

0000:

repeat
    wait 0
until 0AFA:

gosub @CreateDialog
0B34: "showdialog" @ShowDialog
0B34: "hidedialog" @HideDialog

WHILE TRUE
WAIT 0
  
  .........

 

But still I had the same Issue.

 

Replace "SAMP.CmdRet" from :CreateDialog with "return".

Link to comment
Share on other sites

Aight, the problem has fixed, and actually it was my fault...

 

Now, i decide to make Binder it, EX: When i pressed ESC, Dialog.SetVisible(0@, False) | SAMP.SetCursorMode(0).

WHILE TRUE
WAIT 0

if Dialog.IsVisible(0@)
then
		SAMP.SetCursorMode(2)
  
          if 0C89:  key_just_pressed 0x1B
           then
            Dialog.SetVisible(0@, False)
          SAMP.SetCursorMode(0)

        if Dialog.PopEvent(0@, 3@, 4@)
        then
                if 4@ == 1
                then
                        say "You clicked on button 1"
                end
			
                 if 4@ == 2
                 then
                         say "You clicked on button 2"
                 end

                 if 4@ == 3
                 then
                         say "You clicked on button 3"
                 end
             end
         end
     end
END

This method, ESC button can hide the dialog, but his buttons doesn't work at all, so i decide to Bring "If key just pressed" code in below: 

WHILE TRUE
WAIT 0

if Dialog.IsVisible(0@)
then
		SAMP.SetCursorMode(2)

        if Dialog.PopEvent(0@, 3@, 4@)
        then
                if 4@ == 1
                then
                        say "You clicked on button 1"
                end
			
                 if 4@ == 2
                 then
                         say "You clicked on button 2"
                 end

                 if 4@ == 3
                 then
                         say "You clicked on button 3"
                 end
                 
                 if 0C89:  key_just_pressed 0x1B //ESC Button
                    then
                    Dialog.SetVisible(0@, False)
                    SAMP.SetCursorMode(0)
                  end
            end
      end

END

Now, ESC doesn't work, Buttons work well, ? What's the problem !?

 

 

EDIT: Problem fixed

WHILE TRUE
WAIT 0

  if 0C89:  key_just_pressed 0x1B
  then
  Dialog.SetVisible(0@, False)
  SAMP.SetCursorMode(0)
  end

if Dialog.IsVisible(0@)
then
		SAMP.SetCursorMode(2)

        if Dialog.PopEvent(0@, 3@, 4@)
        then
                if 4@ == 1
                then
                        say "You clicked on button 1"
                end
			
                 if 4@ == 2
                 then
                         say "You clicked on button 2"
                 end

                 if 4@ == 3
                 then
                         say "You clicked on button 3"
                 end
            end
      end

END

 

 

Edited by D J C
Link to comment
Share on other sites

After SAMP.SetCursorMode() from ShowDialog label insert the elements which you want in ListBox for dialog.

 

//Dialog.ListBoxInsertElement(DialogID, ListBoxID, "Text", RowID, -1)

Dialog.ListBoxInsertElement(0@, 0, "Row 1", 1, -1)
Dialog.ListBoxInsertElement(0@, 0, "Row 2", 2, -1)
Dialog.ListBoxInsertElement(0@, 0, "Row 3", 3, -1)

 

In loop after verify if dialog is visible and above Dialog.PopEvent add:

//Dialog.ListBoxGetSelectedAndCount(DialogID, ListBoxID, RowSelected, -1)

Dialog.ListBoxGetSelectedAndCount(0@, 0, 5@, -1)

 

Modify verification if you clicked on X button and add verification for selected RowID:

if  4@ == 1 //ButtonID
then
        if 5@ == 1 //RowID
        then
                chatmsg "You selected Row1 and pressed Button1" -1
        end
end

Further you manage on your own to continue

Link to comment
Share on other sites

WHILE TRUE
WAIT 0

  if 0C89:  key_just_pressed 0x1B
  then
  Dialog.SetVisible(0@, False)
  SAMP.SetCursorMode(0)
  end

if Dialog.IsVisible(0@)
then              
	SAMP.SetCursorMode(2)
    Dialog.ListBoxGetSelectedAndCount(0@, 1, 5@, -1) 
    if Dialog.PopEvent(0@, 3@, 4@)
        then
            if 4@ == 1 //Select
                then
                   if 5@ == 1 //RowID
                    then
                    chatmsg "You selected Row 1 and pressed button 1" -1
                    wait 1000 //Anti spam
                    end
                
                   if 5@ == 2 //RowID
                    then
                    chatmsg "You selected Row 2 and pressed button 2" -1
                    wait 1000 //Anti spam
                    end
                
                   if 5@ == 3 //RowID
                    then
                    chatmsg "You selected Row 3 and pressed button 3" -1
                    wait 1000 //Anti spam
                    end               
            end
			
                 if 4@ == 2 //Exit
                 then
                      Dialog.SetVisible(0@, False)
                      SAMP.SetCursorMode(0)
                 end
            end
       end
END

 

Seems I have mistake here, Now... When:

I select "Row 1" Doesn't work.

I select "Row 2" This gonna work -> chatmsg "You selected Row 1 and pressed button 1" -1

I select "Row 3" This gonna work ->  chatmsg "You selected Row 2 and pressed button 2" -1

 

:CreateDialog
Dialog.Create(0@, "DialogTitle")
SAMP.GetScreenResolution(1@, 2@)
1@ /= 2
2@ /= 2 
1@ -= 100
2@ -= 100
Dialog.SetRECT(0@, 1@, 2@, 469, 410)
Dialog.AddListBox(0@, 1, 3, 3, 460, 340)
Dialog.AddButton(0@, 1, "Select", 30, 350, 150, 35)
Dialog.AddButton(0@, 2, "Exit", 250, 350, 150, 35)

Dialog.ListBoxInsertElement(0@, 1, "Row 1", 1, -1)
Dialog.ListBoxInsertElement(0@, 1, "Row 2", 2, -1)
Dialog.ListBoxInsertElement(0@, 1, "Row 3", 3, -1)

What is your solution?

Link to comment
Share on other sites

12 hours ago, D J C said:

WHILE TRUE
WAIT 0

  if 0C89:  key_just_pressed 0x1B
  then
  Dialog.SetVisible(0@, False)
  SAMP.SetCursorMode(0)
  end

if Dialog.IsVisible(0@)
then              
	SAMP.SetCursorMode(2)
    Dialog.ListBoxGetSelectedAndCount(0@, 1, 5@, -1) 
    if Dialog.PopEvent(0@, 3@, 4@)
        then
            if 4@ == 1 //Select
                then
                   if 5@ == 1 //RowID
                    then
                    chatmsg "You selected Row 1 and pressed button 1" -1
                    wait 1000 //Anti spam
                    end
                
                   if 5@ == 2 //RowID
                    then
                    chatmsg "You selected Row 2 and pressed button 2" -1
                    wait 1000 //Anti spam
                    end
                
                   if 5@ == 3 //RowID
                    then
                    chatmsg "You selected Row 3 and pressed button 3" -1
                    wait 1000 //Anti spam
                    end               
            end
			
                 if 4@ == 2 //Exit
                 then
                      Dialog.SetVisible(0@, False)
                      SAMP.SetCursorMode(0)
                 end
            end
       end
END

 

Seems I have mistake here, Now... When:

I select "Row 1" Doesn't work.

I select "Row 2" This gonna work -> chatmsg "You selected Row 1 and pressed button 1" -1

I select "Row 3" This gonna work ->  chatmsg "You selected Row 2 and pressed button 2" -1

 


:CreateDialog
Dialog.Create(0@, "DialogTitle")
SAMP.GetScreenResolution(1@, 2@)
1@ /= 2
2@ /= 2 
1@ -= 100
2@ -= 100
Dialog.SetRECT(0@, 1@, 2@, 469, 410)
Dialog.AddListBox(0@, 1, 3, 3, 460, 340)
Dialog.AddButton(0@, 1, "Select", 30, 350, 150, 35)
Dialog.AddButton(0@, 2, "Exit", 250, 350, 150, 35)

Dialog.ListBoxInsertElement(0@, 1, "Row 1", 1, -1)
Dialog.ListBoxInsertElement(0@, 1, "Row 2", 2, -1)
Dialog.ListBoxInsertElement(0@, 1, "Row 3", 3, -1)

What is your solution?

Try to to modify verification for RowID to start from 0, not 1.

Link to comment
Share on other sites

  • Tupi locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.