CLEO Help Help with this code

CLEO related
Status
Not open for further replies.

mezo312

Member
Joined
May 8, 2020
Messages
20
Reaction score
0
Location
Egypt
Code:
{$CLEO}
0000: handgun/heavyweapon switcher by ajom

const
    CURRENTWEAPONSLOT = 31@
  
    TRIGGERKEY = 69 // E key
end
CURRENTWEAPONSLOT = 3 // Default to handgun slot

while true
    wait 0
    if 0AB0:   key_pressed TRIGGERKEY
    then
        04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot CURRENTWEAPONSLOT weapon 0@ ammo 1@ model 2@
        if 1@ > 0 // has bullets
        then
            01B9: set_actor $PLAYER_ACTOR armed_weapon_to 0@
            if CURRENTWEAPONSLOT == 3
            then CURRENTWEAPONSLOT = 8 // heavy weapon slot
            else CURRENTWEAPONSLOT = 3 // handgun weapon slot
            end
        end
        while 0AB0:   key_pressed TRIGGERKEY // anti key spam
            wait 0
        end
    end
end
Someone made me this code and i don't know how to actually make it a file so please help me with that
 

mezo312

Member
Joined
May 8, 2020
Messages
20
Reaction score
0
Location
Egypt
It's actually not doing what it's supposed to do it's supposed to switch from my handgun which is deagle to shotgun and back to deagle so it's easier to litefoot
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
It's actually not doing what it's supposed to do it's supposed to switch from my handgun which is deagle to shotgun and back to deagle so it's easier to litefoot

It is good to clarify your goal clearly. You said at the Collection Request thread last time that you want a mod that switch between handgun and heavy weapon. This Script will do it:
Code:
{$CLEO}
0000: handgun/heavyweapon switcher by ajom

const
    CURRENTWEAPONSLOT = 31@
    ISENABLED = 30@
 
    TRIGGERKEY = 69 // E key
end
CURRENTWEAPONSLOT = 3 // Default to handgun slot
ISENABLED = true

while true
    wait 0

    if 0ADC:   test_cheat "gungale"
    then
        0B12: ISENABLED = ISENABLED XOR 1
        0AD1: show_formatted_text_highpriority "~g~Handgun/HeavyGun Switcher: ~y~%d" time 2000 ISENABLED
    end

    if and
        ISENABLED == true
        0AB0:   key_pressed TRIGGERKEY
    then
        04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot CURRENTWEAPONSLOT weapon 0@ ammo 1@ model 2@
        if and
            0491:   actor $PLAYER_ACTOR has_weapon 0@
            1@ > 0 // has bullets
        then
            0A96: 2@ = actor $PLAYER_ACTOR struct
            while 82D8: not actor $PLAYER_ACTOR current_weapon == 0@
                if and
                    0491:   actor $PLAYER_ACTOR has_weapon 0@
                    1@ > 0 // has bullets
                then
                    0AA6: call_method 0x5E6280 struct 2@ params 1 pop 0 0@ // force change weapon
                    wait 0
                       041A: 1@ = actor $PLAYER_ACTOR weapon 0@ ammo
                else break
                end
            end
        end
        
        gosub @changeslot
        04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot CURRENTWEAPONSLOT weapon 0@ ammo 1@ model 2@
        if or
            8491: not actor $PLAYER_ACTOR has_weapon 0@
            1@ <= 0 // has no bullets
        then gosub @changeslot
        end
        
        while 0AB0:   key_pressed TRIGGERKEY // anti key spam
            wait 0
        end
    end
end

:changeslot
    if CURRENTWEAPONSLOT == 3
    then CURRENTWEAPONSLOT = 8 // 8 = heavy weapon slot ; 4 = shotgun
    else CURRENTWEAPONSLOT = 3 // handgun weapon slot
    end
return



If you want to switch only by handgun and shotgun, then,
Replace this line :
Code:
CURRENTWEAPONSLOT = 8 // 8 = heavy weapon slot ; 4 = shotgun
With this:
Code:
CURRENTWEAPONSLOT = 4 // 8 = heavy weapon slot ; 4 = shotgun
 

mezo312

Member
Joined
May 8, 2020
Messages
20
Reaction score
0
Location
Egypt
It is good to clarify your goal clearly. You said at the Collection Request thread last time that you want a mod that switch between handgun and heavy weapon. This Script will do it:
Code:
{$CLEO}
0000: handgun/heavyweapon switcher by ajom

const
    CURRENTWEAPONSLOT = 31@
    ISENABLED = 30@

    TRIGGERKEY = 69 // E key
end
CURRENTWEAPONSLOT = 3 // Default to handgun slot
ISENABLED = true

while true
    wait 0

    if 0ADC:   test_cheat "gungale"
    then
        0B12: ISENABLED = ISENABLED XOR 1
        0AD1: show_formatted_text_highpriority "~g~Handgun/HeavyGun Switcher: ~y~%d" time 2000 ISENABLED
    end

    if and
        ISENABLED == true
        0AB0:   key_pressed TRIGGERKEY
    then
        04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot CURRENTWEAPONSLOT weapon 0@ ammo 1@ model 2@
        if and
            0491:   actor $PLAYER_ACTOR has_weapon 0@
            1@ > 0 // has bullets
        then
            0A96: 2@ = actor $PLAYER_ACTOR struct
            while 82D8: not actor $PLAYER_ACTOR current_weapon == 0@
                if and
                    0491:   actor $PLAYER_ACTOR has_weapon 0@
                    1@ > 0 // has bullets
                then
                    0AA6: call_method 0x5E6280 struct 2@ params 1 pop 0 0@ // force change weapon
                    wait 0
                       041A: 1@ = actor $PLAYER_ACTOR weapon 0@ ammo
                else break
                end
            end
        end
       
        gosub @changeslot
        04B8: get_weapon_data_from_actor $PLAYER_ACTOR slot CURRENTWEAPONSLOT weapon 0@ ammo 1@ model 2@
        if or
            8491: not actor $PLAYER_ACTOR has_weapon 0@
            1@ <= 0 // has no bullets
        then gosub @changeslot
        end
       
        while 0AB0:   key_pressed TRIGGERKEY // anti key spam
            wait 0
        end
    end
end

:changeslot
    if CURRENTWEAPONSLOT == 3
    then CURRENTWEAPONSLOT = 8 // 8 = heavy weapon slot ; 4 = shotgun
    else CURRENTWEAPONSLOT = 3 // handgun weapon slot
    end
return



If you want to switch only by handgun and shotgun, then,
Replace this line :
Code:
CURRENTWEAPONSLOT = 8 // 8 = heavy weapon slot ; 4 = shotgun
With this:
Code:
CURRENTWEAPONSLOT = 4 // 8 = heavy weapon slot ; 4 = shotgun

I'm sorry for that, but can you please make it a .cs file cuz when i copied the code and put it in a .cs file it crashed my game
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
I'm sorry for that, but can you please make it a .cs file cuz when i copied the code and put it in a .cs file it crashed my game

You need to learn how to compile a Cleo code:
  1. Save the code above to a "ajom.txt" file
  2. Download SANNY BUILDER
  3. Install Sanny builder and Follow its procedures for San Andreas
  4. At the the upper part click "tools>options", then click the "Formats" Tab, then the "Case converting" click "As is".
  5. At file>open, browse ajom.txt file
  6. Press F6 to Compile the script. An ajom.cs file will be saved at the directory of ajom.txt
I am not being hard on you, but trust me when you know how to compile Cleo codes into .cs files, you will not need to rely on other people when it comes to this.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Also you need to install the SAMPFUNCS SDK inside Sanny Builder directory, see the picture below.
 

Attachments

  • Screenshot_2020-11-29-19-56-30-16.jpg
    Screenshot_2020-11-29-19-56-30-16.jpg
    395 KB · Views: 15
Status
Not open for further replies.
Top