CLEO Help SF Dialog EditBox

CLEO related
Status
Not open for further replies.

hahahafuccoff

Member
Joined
Jun 6, 2018
Messages
16
Reaction score
0
I need help with SF Dialogs again  :iknowwhatyoudidthere: 
How can i set a variable if is typed in editboxes a command ?
Example:
Dialog.AddEditBox(1@, 1, "Type something", 33, 35, 195, 40)
Dialog.AddButton(1@, 3, "Send", 56, 86, 155, 40)
When i am clicking the button 3 Send, i want to be checked what is in editbox, like if in editbox is "shit"  to close the dialog permanently (can't be opened again)  and open another one, if is not, like "word", "other shit" "asafasfsafagasg", to chatmsg " Wrong text 1/3" , "Wrong text 2/3" and "Wrong text 3/3", at 3/3 to stop cleo. I mean if i type "word" in editbox then press the buton, to chatmsg "Wrong text 1/3", if i press again to show "wrong text 2/3" and if i press again "wrong text 3/3", close dialogs and stop the cleo mod.
If you don't understand what i tried to do, is ok, I learned English in Uganda (jk)

Well i know this:
0B81: dialog 1@ pop_event_to 2@ control_id_to 3@

IF 3@ == 3
THEN
//something
END

But i don't know the rest, it's second time when i work with sf dialogs and i didn't use editbox before....
 

_=Gigant=_

Well-known member
Joined
Mar 21, 2017
Messages
353
Reaction score
16
hahahafuccoff said:
I need help with SF Dialogs again  :iknowwhatyoudidthere: 
How can i set a variable if is typed in editboxes a command ?
Example:
Dialog.AddEditBox(1@, 1, "Type something", 33, 35, 195, 40)
Dialog.AddButton(1@, 3, "Send", 56, 86, 155, 40)

here for example 

          if 3@ == 1 // if is button pressed
            then    
            alloc 16@ 100  // always alloc memory for text                                
            0B89: dialog 0@ get_control 2 text_to 16@
// do stuff

here is example when id of some player is entered in box it will show that player skin id 

          if 3@ == 1 // button
            then                               
            alloc 16@ 100         
            0B89: dialog 0@ get_control 2 text_to 16@ // 2 is id for edit box
            if
            0AD4: 16@ = scan_string 16@ format "%d" 15@
            if
            Samp.IsPlayerConnected(15@)            
            then
            0B20: samp 18@ = actor_handle_by_samp_player_id 15@
            0665: get_actor 18@ model_to 17@
            chatmsg "Skin ID {00FF00}%d" -1 17@
            end
            free 16@
          end 

here change name 

            if 3@ == 1   // change name text box
            then                               
            alloc 16@ 200         
            0B89: dialog 1@ get_control 2 text_to 19@
            if 
            0AD4: 16@ = scan_string 16@ format "%s" 19@ // my name's jeff
            then  
            0B35: get_params_to 19@         
            0B28: disconnect 0
            0B29: set_nickname 19@
            0B27: set_gamestate 1
            end         
            free 16@
            end 

and here is full example with dialog 


Code:
{$CLEO}
0000:

repeat
wait 0
until Samp.Available()

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}OK", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, "Input New Name" ,105 ,5, 200, 35)
Dialog.AddButton(1@, 3, "{00ff00}Get Skin", 5, 35, 80, 22)
Dialog.AddEditBox(1@, 4, "Player ID" ,105 ,37, 200, 35)

Dialog.SetVisible(1@, 0)

while true
wait 0

   if Dialog.IsVisible(1@)
   then   
        0B81: dialog 1@ pop_event_to 2@ control_id_to 3@   

          if 3@ == 3 // button
            then                               
            alloc 16@ 100         
            0B89: dialog 1@ get_control 4 text_to 16@ // 2 is id for edit box
            if
            0AD4: 16@ = scan_string 16@ format "%d" 15@
            if
            Samp.IsPlayerConnected(15@)            
            then
            0B20: samp 18@ = actor_handle_by_samp_player_id 15@
            0665: get_actor 18@ model_to 17@
            chatmsg "Skin ID {00FF00}%d" -1 17@
            end
            free 16@
          end 

          if 3@ == 1   // change name text box
            then                               
            alloc 16@ 200         
            0B89: dialog 1@ get_control 2 text_to 19@
            if 
            0AD4: 16@ = scan_string 16@ format "%s" 19@ // my name's jeff
            then  
            0B35: get_params_to 19@         
            0B28: disconnect 0
            0B29: set_nickname 19@
            0B27: set_gamestate 1
            end         
            free 16@
           end 
       end    

if 
0AB0: 88 // press X to open dialog in game and test it
then
0B12: 0@ = 0@ XOR 1
if
0@ == true
then
wait 200  
Dialog.SetVisible(1@, 1)
SAMP.ToggleCursor(1)
else
wait 200 
Dialog.SetVisible(1@,0)
SAMP.ToggleCursor(0)
end
end     

END
 

hahahafuccoff

Member
Joined
Jun 6, 2018
Messages
16
Reaction score
0
_=Gigant=_ said:
hahahafuccoff said:
I need help with SF Dialogs again  :iknowwhatyoudidthere: 
How can i set a variable if is typed in editboxes a command ?
Example:
Dialog.AddEditBox(1@, 1, "Type something", 33, 35, 195, 40)
Dialog.AddButton(1@, 3, "Send", 56, 86, 155, 40)

here for example 

          if 3@ == 1 // if is button pressed
            then    
            alloc 16@ 100  // always alloc memory for text                                
            0B89: dialog 0@ get_control 2 text_to 16@
// do stuff

here is example when id of some player is entered in box it will show that player skin id 

          if 3@ == 1 // button
            then                               
            alloc 16@ 100         
            0B89: dialog 0@ get_control 2 text_to 16@ // 2 is id for edit box
            if
            0AD4: 16@ = scan_string 16@ format "%d" 15@
            if
            Samp.IsPlayerConnected(15@)            
            then
            0B20: samp 18@ = actor_handle_by_samp_player_id 15@
            0665: get_actor 18@ model_to 17@
            chatmsg "Skin ID {00FF00}%d" -1 17@
            end
            free 16@
          end 

here change name 

            if 3@ == 1   // change name text box
            then                               
            alloc 16@ 200         
            0B89: dialog 1@ get_control 2 text_to 19@
            if 
            0AD4: 16@ = scan_string 16@ format "%s" 19@ // my name's jeff
            then  
            0B35: get_params_to 19@         
            0B28: disconnect 0
            0B29: set_nickname 19@
            0B27: set_gamestate 1
            end         
            free 16@
            end 

and here is full example with dialog 


Code:
{$CLEO}
0000:

repeat
wait 0
until Samp.Available()

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}OK", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, "Input New Name" ,105 ,5, 200, 35)
Dialog.AddButton(1@, 3, "{00ff00}Get Skin", 5, 35, 80, 22)
Dialog.AddEditBox(1@, 4, "Player ID" ,105 ,37, 200, 35)

Dialog.SetVisible(1@, 0)

while true
wait 0

   if Dialog.IsVisible(1@)
   then   
        0B81: dialog 1@ pop_event_to 2@ control_id_to 3@   

          if 3@ == 3 // button
            then                               
            alloc 16@ 100         
            0B89: dialog 1@ get_control 4 text_to 16@ // 2 is id for edit box
            if
            0AD4: 16@ = scan_string 16@ format "%d" 15@
            if
            Samp.IsPlayerConnected(15@)            
            then
            0B20: samp 18@ = actor_handle_by_samp_player_id 15@
            0665: get_actor 18@ model_to 17@
            chatmsg "Skin ID {00FF00}%d" -1 17@
            end
            free 16@
          end 

          if 3@ == 1   // change name text box
            then                               
            alloc 16@ 200         
            0B89: dialog 1@ get_control 2 text_to 19@
            if 
            0AD4: 16@ = scan_string 16@ format "%s" 19@ // my name's jeff
            then  
            0B35: get_params_to 19@         
            0B28: disconnect 0
            0B29: set_nickname 19@
            0B27: set_gamestate 1
            end         
            free 16@
           end 
       end    

if 
0AB0: 88 // press X to open dialog in game and test it
then
0B12: 0@ = 0@ XOR 1
if
0@ == true
then
wait 200  
Dialog.SetVisible(1@, 1)
SAMP.ToggleCursor(1)
else
wait 200 
Dialog.SetVisible(1@,0)
SAMP.ToggleCursor(0)
end
end     

END

Well well, i guess my life would be a mess without you
 
Status
Not open for further replies.
Top