MENU BUTTON AND CHECKBOX

MalikeiraOPoder

Active member
Joined
Mar 16, 2019
Messages
100
Reaction score
2
Here is my code

PHP:
{$CLEO}
{$INCLUDE SF}

thread "MENU TEST"

CONST
PLAYER          $PLAYER_ACTOR
CHAR            $PLAYER_CHAR
D_HELP          666
D_WIDTH         160    // 320
D_HEIGHT        135    // 305
K_MENU          113 //F2 for open the Dialog
HEX_G           0x66FF33 //Green
END

repeat
    wait 40
until SAMP.Available()

//DIALOG
Dialog.Create(20@, "MENU")
Dialog.SetRECT(20@, 0, 0, D_WIDTH, D_HEIGHT)
Dialog.AddCheckBox(20@, 1, "NoReload Guns", 5, 30, 180, 15)
Dialog.AddButton(20@, 2, "NoSPREAD", 5, 70, 125, 25)
Dialog.SetVisible(20@, 0)

wait 3000

WHILE TRUE
WAIT 0
        IF
        key_down K_MENU 
        THEN
            IF 0B87: dialog 20@ is_visible
            THEN
                IF 8B92: not dialog 20@ is_checked 1
                THEN
                0330: CHAR 0
                04D8: PLAYER 1
                08C6: PLAYER 0
                END
                02AB: PLAYER 0 0 0 0 0
                0@ = 0
            ELSE
                00A0: PLAYER to 1@ 2@ 3@
                0980: 1@ 2@ 3@ 200.0
                0@ = 1
            END
            call @ToggleDialog 2 20@ 0@
            wait 200
        END

        Dialog.PopEvent(20@, 0, 12@)
        
        IF 12@ > 0
        THEN 
        018C: play_sound 1083 at 0.0 0.0 0.0
        END
        
        IF
        0B92: dialog 20@ is_checked 1 
          THEN
          // Code NoReload Guns here
          END
        
        IF 12@ == 2
            THEN
                alloc 0@ 20
                format 0@ "{%X}NoSPREAD: ON" HEX_G
                Dialog.SetControlText(20@, 2, 0@)
                free 0@
                // noSpread Code Here when is ON
            ELSE
                Dialog.SetControlText(20@, 2, "NoSPREAD")
                // noSpread Code here When is OFF
            END
        END

:ToggleDialog
0B86: 0@ 1@
0B5D: 1@
ret 0




I want to add this code NoReloadGuns on CheckBox for work
Below is the Code

PHP:
Player.Defined(CHAR)
THEN 
0470: 1@ = actor PLAYER current_weapon 
Actor.GiveWeaponAndAmmo(PLAYER, 1@, 0)
wait 150
end


and i want to add NoSpread on AddButton, when is ON , stay green the button and when is off, stay default
Someone can help me ?
 

MalikeiraOPoder

Active member
Joined
Mar 16, 2019
Messages
100
Reaction score
2
I dont like sobeit bro, i just need this 2 function for me , can u help me ?
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
-_-

PHP:
{$CLEO .cs}
{$INCLUDE SF}

Thread "MENU TEST"

CONST
PLAYER          $PLAYER_ACTOR
CHAR            $PLAYER_CHAR
D_HELP          666
D_WIDTH         160    // 320
D_HEIGHT        135    // 305
K_MENU          113 //F2 for open the Dialog
HEX_G           0x66FF33 //Green
END

repeat
    wait 40
until SAMP.Available()

//DIALOG
Dialog.Create(20@, "MENU")
Dialog.SetRECT(20@, 0, 0, D_WIDTH, D_HEIGHT)
Dialog.AddCheckBox(20@, 1, "NoReload Guns", 5, 30, 180, 15)
Dialog.AddButton(20@, 2, "NoSPREAD", 5, 70, 125, 25)
Dialog.SetVisible(20@, 0)

wait 3000

WHILE TRUE
WAIT 0

IF
0AB0: K_MENU 
THEN
    REPEAT
        WAIT 0
    UNTIL 8AB0: K_MENU // ANTI SPAM KEY
    
    IF 0B87: dialog 20@ is_visible
    THEN
        IF 
        8B92:  dialog 20@ checkbox 1 is_checked
        THEN
            0330: set_player CHAR infinite_run 0
            04D8: set_actor PLAYER drowns_in_water 1
            08C6: set_actor PLAYER stay_on_bike 0
        END
        02AB: set_actor PLAYER immunities BP 0 FP 0 EP 0 CP 0 MP 0
        0@ = 0
    ELSE
        00A0: store_actor PLAYER position_to 1@ 2@ 3@
        0980: extinguish_all_fires_at 1@ 2@ 3@ radius 200.0
        0@ = 1
    END
    0AB1:  @ToggleDialog 2 20@ 0@
    wait 200
END
        
IF
0B81: dialog 20@ pop_event_to 22@ control_id_to 12@
THEN 
    //018C: play_sound 1083 at 0.0 0.0 0.0
    IF AND
    12@ == 2 // ID
    22@ == 257 // pressed
    THEN
        IF
        10@ == FALSE
        THEN
            10@ = TRUE
        ELSE
            10@ = FALSE
        END
    END
        
    IF 
    10@ == TRUE
    THEN
        IF
        0B87: dialog 20@ is_visible
        THEN
            alloc 0@ 20
            format 0@ "{%X}NoSPREAD: ON" HEX_G
            Dialog.SetControlText(20@, 2, 0@)
            free 0@
            // noSpread Code Here when is ON
        END
    ELSE
        IF
        0B87: dialog 20@ is_visible
        THEN
            Dialog.SetControlText(20@, 2, "NoSPREAD")
            // noSpread Code here When is OFF
        END
    END
    
END // END 0B81: dialog 20@ pop_event_to 22@ control_id_to 12@

END // WHILE TRUE

:ToggleDialog
0B86: 0@ 1@
0B5D: 1@
ret 0
 
Top