CLEO Help Edit box to change key

CLEO related
Status
Not open for further replies.

MalikeiraOPoder

Active member
Joined
Mar 16, 2019
Messages
100
Reaction score
2
sup my homies, i need a help, idk how to do that shit..

i want a EditBox to change my activation to open a Dialog..
i want to put when i chooser a code and press in "Apply" it will close my dialog and to open i need to type new code..

example : Default code is "nugg" and i changed to "pussi" when i press Apply, it will close my dialog and i will need to type pussi to open...


is here below my code how example...

PHP:
{$CLEO}
0000:

repeat
wait 0
until Samp.Available()

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}Apply", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, "nugg" ,105 ,5, 200, 35)

Dialog.SetVisible(1@, 0)

while true
wait 0

            if 
        0ADC:   test_cheat "nugg"    // To change that shit
        then
            if
            30@ == false
            then
                30@ = true
            else
                30@ = false
            end
        end
        
                if
                30@ == true
                then 
                        if 
                            0AB0: 88 
                            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


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

          if 3@ == 1  
            then                               
            alloc 16@ 200         
            0B89: dialog 1@ get_control 2 text_to 19@
            if 
            0AD4: 16@ = scan_string 16@ format "%s" 19@
            then  
            
                    //something here, i think

            end         
            free 16@
           end 
       end    
    

END


@Opcode.eXe @springfield @monday @Zin etc...
 
Last edited:

Zin

Expert
Joined
Aug 1, 2013
Messages
1,698
Reaction score
106
Rather simple actually just store the string you enter to a standard gtasa string var not like a sampfuncs one and you can just use it with test_cheat opcode. Cleaned some stuff up for you, always try to keep the code easy to read.
Code:
{$CLEO}
0000:

REPEAT
    WAIT 0
UNTIL Samp.Available()

30@ = FALSE
0@ = FALSE
06D2: 19@v = "nugg" // @v = string

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}Apply", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, 19@v ,105 ,5, 200, 35)

Dialog.SetVisible(1@, 0)


WHILE TRUE
WAIT 0

    IF
        0ADC:   test_cheat 19@v    // 19@v points towards the string.
    THEN
        0B12: 30@ = 30@ XOR 1 // Always use bitwise aka "XOR" for a variable toggle like this, you have used XOR elsewhere but not here, don't know why.
    END
        
    IF
        30@ == TRUE
    THEN
        IF
            0AB0: 88
        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


    IF
        Dialog.IsVisible(1@)
    THEN   
        0B81: dialog 1@ pop_event_to 2@ control_id_to 3@   
        IF
            3@ == 1 
        THEN                                       
            0B89: dialog 1@ get_control 2 text_to 19@v
        END
    END   
    
END
 

MalikeiraOPoder

Active member
Joined
Mar 16, 2019
Messages
100
Reaction score
2
Rather simple actually just store the string you enter to a standard gtasa string var not like a sampfuncs one and you can just use it with test_cheat opcode. Cleaned some stuff up for you, always try to keep the code easy to read.
Code:
{$CLEO}
0000:

REPEAT
    WAIT 0
UNTIL Samp.Available()

30@ = FALSE
0@ = FALSE
06D2: 19@v = "nugg" // @v = string

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}Apply", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, 19@v ,105 ,5, 200, 35)

Dialog.SetVisible(1@, 0)


WHILE TRUE
WAIT 0

    IF
        0ADC:   test_cheat 19@v    // 19@v points towards the string.
    THEN
        0B12: 30@ = 30@ XOR 1 // Always use bitwise aka "XOR" for a variable toggle like this, you have used XOR elsewhere but not here, don't know why.
    END
       
    IF
        30@ == TRUE
    THEN
        IF
            0AB0: 88
        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


    IF
        Dialog.IsVisible(1@)
    THEN  
        0B81: dialog 1@ pop_event_to 2@ control_id_to 3@  
        IF
            3@ == 1
        THEN                                      
            0B89: dialog 1@ get_control 2 text_to 19@v
        END
    END  
   
END
ty my friend and... i dont knew what means "v" lol, thank u so much
 

MalikeiraOPoder

Active member
Joined
Mar 16, 2019
Messages
100
Reaction score
2
another thing...
to show my code... what i have to do.. look what i did..

PHP:
{$CLEO}
0000:

REPEAT
    WAIT 0
UNTIL Samp.Available()

30@ = FALSE
0@ = FALSE
06D2: 19@v = "nugg" // @v = string

Dialog.Create(1@, "")
Dialog.SetRECT(1@, 100, 100, 335, 100)
Dialog.AddButton(1@, 1, "{00ff00}Apply", 5, 5, 80, 22)
Dialog.AddEditBox(1@, 2, 19@v ,105 ,5, 200, 35)
Dialog.AddStatic(1@, 3, "Code is:", 55, 30, 100, 55)

Dialog.SetVisible(1@, 0)


WHILE TRUE
WAIT 0

    IF
        0ADC:   test_cheat 19@v    // 19@v points towards the string.
    THEN
        0B12: 30@ = 30@ XOR 1 // Always use bitwise aka "XOR" for a variable toggle like this, you have used XOR elsewhere but not here, don't know why.
    END
        
    IF
        30@ == TRUE
    THEN
        IF
            0AB0: 88
        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


    IF
        Dialog.IsVisible(1@)
    THEN   
        0B81: dialog 1@ pop_event_to 2@ control_id_to 3@   
        IF
            3@ == 1 
        THEN                                       
            0B89: dialog 1@ get_control 2 text_to 19@v
        END
    END   
   
  /////////////////////// this part  here
IF Dialog.IsVisible(1@)
    THEN
        alloc 14@ 15
        format 14@ "Code is: %d" 24@v
        Dialog.SetControlText(1@, 3, 14@)
        free 14@
    end

    // this is not working, is crashing zz

END



whats my mistake?
 
Status
Not open for further replies.
Top